Example #1
0
            // initializes and actualizes new instance
            public static InputInfo Create()
            {
                var result = new InputInfo();

                result.Update();

                return result;
            }
    public InputInfo( InputInfo toCopy )
    {
        inputName = toCopy.inputName;
        isAxis = toCopy.isAxis;

        mouseButtonNum = toCopy.mouseButtonNum;

        buttonState = toCopy.buttonState;
        axisValue = toCopy.axisValue;
    }
Example #3
0
        public InputTracker(EventHandler<InputChangedEventArgs> changed)
        {
            var handler = changed;
            if (handler != null)
                Changed += handler;

            disposed = false;

            timerLock = new object();
            timer = new Timer { AutoReset = true, Enabled = false };
            timer.Elapsed += timer_Elapsed;

            initialInfo = InputInfo.Create();
            actualInfo = (InputInfo)initialInfo.Clone();
        }
Example #4
0
        private void btnSetup_Click(object sender, EventArgs e)
        {
            int    index        = 0;
            object selectedItem = null;
            string selectedText = "";

            if (sender == btnSetupP1)
            {
                selectedItem = cboPlayer1.GetEnumValue <InteropEmu.ControllerType>();
                selectedText = cboPlayer1.SelectedItem.ToString();
                index        = 0;
            }
            else if (sender == btnSetupP2)
            {
                selectedItem = cboPlayer2.GetEnumValue <InteropEmu.ControllerType>();
                selectedText = cboPlayer2.SelectedItem.ToString();
                index        = 1;
            }
            else if (sender == btnSetupP3)
            {
                selectedItem = cboPlayer3.GetEnumValue <InteropEmu.ControllerType>();
                selectedText = cboPlayer3.SelectedItem.ToString();
                index        = 2;
            }
            else if (sender == btnSetupP4)
            {
                selectedItem = cboPlayer4.GetEnumValue <InteropEmu.ControllerType>();
                selectedText = cboPlayer4.SelectedItem.ToString();
                index        = 3;
            }
            else if (sender == btnSetupExp)
            {
                selectedItem = cboExpansionPort.GetEnumValue <InteropEmu.ExpansionPortDevice>();
                selectedText = cboExpansionPort.SelectedItem.ToString();
                index        = 0;
            }

            Form      frm       = null;
            InputInfo inputInfo = (InputInfo)Entity;

            if (selectedItem is InteropEmu.ControllerType)
            {
                InteropEmu.ControllerType type = (InteropEmu.ControllerType)selectedItem;
                switch (type)
                {
                case InteropEmu.ControllerType.StandardController:
                case InteropEmu.ControllerType.SnesController:
                    frm = new frmControllerConfig(inputInfo.Controllers[index], index, cboConsoleType.GetEnumValue <ConsoleType>(), type);
                    break;

                case InteropEmu.ControllerType.PowerPad:
                    frm = new frmPowerPadConfig(inputInfo.Controllers[index], index);
                    break;

                case InteropEmu.ControllerType.Zapper:
                    frm = new frmZapperConfig(inputInfo.Zapper);
                    break;

                case InteropEmu.ControllerType.SnesMouse:
                    frm = new frmMouseConfig(inputInfo.SnesMouse);
                    break;

                case InteropEmu.ControllerType.SuborMouse:
                    frm = new frmMouseConfig(inputInfo.SuborMouse);
                    break;

                case InteropEmu.ControllerType.ArkanoidController:
                    frm = new frmMouseConfig(inputInfo.ArkanoidController);
                    break;

                case InteropEmu.ControllerType.VbController:
                    frm = new frmVirtualBoyConfig(inputInfo.Controllers[index], index);
                    break;
                }
            }
            else if (selectedItem is InteropEmu.ExpansionPortDevice)
            {
                InteropEmu.ExpansionPortDevice device = (InteropEmu.ExpansionPortDevice)selectedItem;
                switch (device)
                {
                case InteropEmu.ExpansionPortDevice.FamilyTrainerMat:
                    frm = new frmPowerPadConfig(inputInfo.Controllers[index], index);
                    break;

                case InteropEmu.ExpansionPortDevice.PartyTap:
                    frm = new frmPartytapConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.Pachinko:
                    frm = new frmPachinkoConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.ExcitingBoxing:
                    frm = new frmExcitingBoxingConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.JissenMahjong:
                    frm = new frmJissenMahjongConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.FamilyBasicKeyboard:
                    frm = new frmFamilyBasicKeyboardConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.SuborKeyboard:
                    frm = new frmSuborKeyboardConfig(inputInfo.Controllers[index]);
                    break;

                case InteropEmu.ExpansionPortDevice.Zapper:
                case InteropEmu.ExpansionPortDevice.BandaiHyperShot:
                    frm = new frmZapperConfig(inputInfo.Zapper);
                    break;

                case InteropEmu.ExpansionPortDevice.HoriTrack:
                    frm = new frmMouseConfig(inputInfo.HoriTrack);
                    break;

                case InteropEmu.ExpansionPortDevice.ArkanoidController:
                    frm = new frmMouseConfig(inputInfo.ArkanoidController);
                    break;
                }
            }

            if (frm != null)
            {
                OpenSetupWindow(frm, (Button)sender, selectedText);
            }
        }
Example #5
0
 public void CustomFixedUpdate(InputInfo ii)
 {
 }
Example #6
0
 public void SetParams(string f1, string f2, string o) => this._files = new BFF.InputInfo(f1, f2, o);
Example #7
0
    private ReorderableList.ElementCallbackDelegate DrawElement(SerializedObject pSO, InputInfoList pDrawTarget)
    {
        return((Rect rect, int index, bool isActive, bool isFocused) =>
        {
            InputInfo pCommandInfo = pDrawTarget.listCommandInfo[index];

            rect.width -= 15f;
            rect.x += 10f;

            float fOrigin_RectX = rect.x;
            float fOriginRectWidth = rect.width;

            var pSP_Element = _listCommandInfo.serializedProperty.GetArrayElementAtIndex(index);
            var pProeprty_ListInputInfoList = pSP_Element.FindPropertyRelative(nameof(pCommandInfo.pInputInfoGroup));
            InputInfoElementGroup pInputInfoGroup = EditorCodeHelper.GetTargetObjectOfProperty(pProeprty_ListInputInfoList) as InputInfoElementGroup;

            rect.height = EditorCodeHelper.singleLineHeight;
            rect.width *= 0.5f;
            rect.x += rect.width;

            if (pDrawTarget.pCommandListTarget != null)
            {
                System.Type pCommandType = null;
                var listCommandType = pDrawTarget.pCommandListTarget.GetCommandList();
                foreach (var pType in listCommandType)
                {
                    if (pType.Value.FullName.Equals(pCommandInfo.strCommandTypeName))
                    {
                        pCommandType = pType.Value;
                        break;
                    }
                }

                int iSelectIndex = EditorGUI.Popup(rect, listCommandType.Calculate_SelectIndex(pCommandType), listCommandType.GetNameList());
                pCommandType = listCommandType[iSelectIndex].Value;
                if (pCommandType != null)
                {
                    pCommandInfo.strCommandTypeName = pCommandType.FullName;
                    pCommandInfo.strAssemblyName = pCommandType.Assembly.FullName;
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(pSO.targetObject);
                }
            }
            else
            {
                EditorGUI.LabelField(rect, "Command is Null");
            }

            rect.width = fOriginRectWidth;
            rect.x = fOrigin_RectX;
            pSP_Element.isExpanded = EditorCodeHelper.Foldout(rect, pSP_Element.isExpanded, "Command");
            if (pSP_Element.isExpanded)
            {
                rect.y += EditorCodeHelper.singleLineHeight;
                EditorGUI.PropertyField(rect, pProeprty_ListInputInfoList, true);
            }
        });
    }
 public void PopulateInputInfo(InputInfo inputInfo)
 {
     inputInfo.Populate(controlScheme);
 }
Example #9
0
        public bool PlayerWasDead = false;         // 死亡すると true にセットされる。

        public void Perform()
        {
            DDUtils.Random = new DDRandom(1u, 1u, 1u, 1u);             // 電源パターン確保のため

            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            Func <bool> f_ゴミ回収 = SCommon.Supplier(this.E_ゴミ回収());

            // reset
            {
                RippleEffect.Clear();
                画面分割.Enabled = false;
            }

            this.Player.Reset(false);

            // ★★★★★ ステータス反映
            {
                this.Score        = this.Status.Score;
                this.Player.Power = this.Status.PlayerPower;
                this.Zanki        = this.Status.PlayerZanki;
                this.ZanBomb      = this.Status.PlayerZanBomb;
            }

            for (this.Frame = 0; ; this.Frame++)
            {
                if (!this.Script.EachFrame())                 // シナリオ進行
                {
                    break;
                }

                if (DDConfig.LOG_ENABLED)                 // チート機能
                {
                    if (DDKey.IsPound(DX.KEY_INPUT_PGUP))
                    {
                        this.Player.Power += GameConsts.PLAYER_POWER_PER_LEVEL;
                    }
                    if (DDKey.IsPound(DX.KEY_INPUT_PGDN))
                    {
                        this.Player.Power -= GameConsts.PLAYER_POWER_PER_LEVEL;
                    }
                    DDUtils.ToRange(ref this.Player.Power, 0, GameConsts.PLAYER_POWER_MAX);
                }

                if (DDInput.PAUSE.GetInput() == 1 && 10 < this.Frame)                 // ポーズ
                {
                    this.Pause();

                    if (this.Pause_RestartGame)
                    {
                        GameMaster.RestartFlag = true;
                        break;
                    }
                    if (this.Pause_ReturnToTitleMenu)
                    {
                        GameMaster.ReturnToTitleMenu = true;
                        break;
                    }
                }
                if (DDConfig.LOG_ENABLED && DDKey.GetInput(DX.KEY_INPUT_RETURN) == 1)
                {
                    this.DebugPause();
                }

                this.LastInput = this.Input;                 // 前回のプレイヤー入力を退避

                // プレイヤー入力
                {
                    this.Input.Dir2  = 1 <= DDInput.DIR_2.GetInput();
                    this.Input.Dir4  = 1 <= DDInput.DIR_4.GetInput();
                    this.Input.Dir6  = 1 <= DDInput.DIR_6.GetInput();
                    this.Input.Dir8  = 1 <= DDInput.DIR_8.GetInput();
                    this.Input.Slow  = 1 <= DDInput.A.GetInput();
                    this.Input.Shoot = 1 <= DDInput.B.GetInput();
                    this.Input.Bomb  = 1 <= DDInput.C.GetInput();
                }

                this.Player.LastX = this.Player.X;
                this.Player.LastY = this.Player.Y;

startBornPlayer:
                if (1 <= this.Player.BornFrame)                 // プレイヤー登場中の処理
                {
                    int frm = this.Player.BornFrame - 1;

                    if (GameConsts.PLAYER_BORN_FRAME_MAX < frm)
                    {
                        this.Player.BornFrame = 0;
                        goto endBornPlayer;
                    }
                    this.Player.BornFrame++;
                    double rate = (double)frm / GameConsts.PLAYER_BORN_FRAME_MAX;

                    if (frm == 0)                     // init
                    {
                        this.Player.BornFollowX = GameConsts.FIELD_W * 0.5;
                        this.Player.BornFollowY = GameConsts.FIELD_H * 1.2;
                    }

                    double approachingRate = 0.99 - 0.01 * frm;
                    DDUtils.ToRange(ref approachingRate, 0.0, 1.0);

                    DDUtils.Approach(ref this.Player.BornFollowX, this.Player.X, approachingRate);
                    DDUtils.Approach(ref this.Player.BornFollowY, this.Player.Y, approachingRate);
                }
endBornPlayer:

                //startDeadPlayer:
                if (1 <= this.Player.DeadFrame)                 // プレイヤー死亡中の処理
                {
                    int frm = this.Player.DeadFrame - 1;

                    if (GameConsts.PLAYER_DEAD_FRAME_MAX < frm)
                    {
                        if (this.Zanki <= 0)                         // 残機不足のため終了
                        {
                            GameMaster.ReturnToTitleMenu = true;
                            break;
                        }
                        this.Zanki--;
                        this.Player.Reset(true);
                        goto startBornPlayer;
                    }
                    this.Player.DeadFrame++;

                    if (frm == 0)                     // init
                    {
                        this.DeadPlayerMoment();
                        this.PlayerEffects.Add(SCommon.Supplier(Effects.PlayerDead(this.Player.X, this.Player.Y)));
                    }
                    goto endPlayerMove;
                }
                //endDeadPlayer:

                //startBombPlayer:
                if (1 <= this.Player.BombFrame)                 // ボム使用中の処理
                {
                    int frm = this.Player.BombFrame - 1;

                    if (GameConsts.PLAYER_BOMB_FRAME_MAX < frm)
                    {
                        this.Player.BombFrame = 0;
                        goto endBombPlayer;
                    }
                    this.Player.BombFrame++;

                    if (frm == 0)                     // init
                    {
                        this.Player.Bomb();
                    }
                }
endBombPlayer:

                //startPlayerMove:
                // プレイヤー移動
                {
                    bool d2 = this.Input.Dir2;
                    bool d4 = this.Input.Dir4;
                    bool d6 = this.Input.Dir6;
                    bool d8 = this.Input.Dir8;

                    double speed;

                    if (this.Input.Slow)
                    {
                        speed = 2.5;
                    }
                    else
                    {
                        speed = 5.0;
                    }

                    double nanameSpeed = speed / Math.Sqrt(2.0);

                    if (d2 && d4)                     // 左下
                    {
                        this.Player.X -= nanameSpeed;
                        this.Player.Y += nanameSpeed;
                    }
                    else if (d2 && d6)                     // 右下
                    {
                        this.Player.X += nanameSpeed;
                        this.Player.Y += nanameSpeed;
                    }
                    else if (d4 && d8)                     // 左上
                    {
                        this.Player.X -= nanameSpeed;
                        this.Player.Y -= nanameSpeed;
                    }
                    else if (d6 && d8)                     // 右上
                    {
                        this.Player.X += nanameSpeed;
                        this.Player.Y -= nanameSpeed;
                    }
                    else if (d2)                     // 下
                    {
                        this.Player.Y += speed;
                    }
                    else if (d4)                     // 左
                    {
                        this.Player.X -= speed;
                    }
                    else if (d6)                     // 右
                    {
                        this.Player.X += speed;
                    }
                    else if (d8)                     // 上
                    {
                        this.Player.Y -= speed;
                    }

                    DDUtils.ToRange(ref this.Player.X, 0.0, (double)GameConsts.FIELD_W);
                    DDUtils.ToRange(ref this.Player.Y, 0.0, (double)GameConsts.FIELD_H);

                    if (d4)                     // 左
                    {
                        DDUtils.Minim(ref this.Player.XMoveFrame, 0);
                        this.Player.XMoveFrame--;
                    }
                    else if (d6)                     // 右
                    {
                        DDUtils.Maxim(ref this.Player.XMoveFrame, 0);
                        this.Player.XMoveFrame++;
                    }
                    else
                    {
                        this.Player.XMoveFrame = 0;
                    }

                    if (d8)                     // 上
                    {
                        DDUtils.Minim(ref this.Player.YMoveFrame, 0);
                        this.Player.YMoveFrame--;
                    }
                    else if (d2)                     // 下
                    {
                        DDUtils.Maxim(ref this.Player.YMoveFrame, 0);
                        this.Player.YMoveFrame++;
                    }
                    else
                    {
                        this.Player.YMoveFrame = 0;
                    }

                    DDUtils.Approach(ref this.Player.XMoveRate, DDUtils.Sign(this.Player.XMoveFrame), 0.95);
                    DDUtils.Approach(ref this.Player.YMoveRate, DDUtils.Sign(this.Player.YMoveFrame), 0.95);
                }
endPlayerMove:

                if (this.Input.Slow)
                {
                    DDUtils.Maxim(ref this.Player.SlowFrame, 0);
                    this.Player.SlowFrame++;
                }
                else
                {
                    DDUtils.Minim(ref this.Player.SlowFrame, 0);
                    this.Player.SlowFrame--;
                }

                if (this.Input.Shoot)
                {
                    DDUtils.Maxim(ref this.Player.ShootFrame, 0);
                    this.Player.ShootFrame++;
                }
                else
                {
                    DDUtils.Minim(ref this.Player.ShootFrame, 0);
                    this.Player.ShootFrame--;
                }

                DDUtils.Approach(ref this.Player.SlowRate, this.Player.SlowFrame < 0 ? 0.0 : 1.0, 0.85);
                DDUtils.Approach(ref this.Player.ShootRate, this.Player.ShootFrame < 0 ? 0.0 : 1.0, 0.85);

                if (this.LastInput.Shoot && this.Input.Shoot && SCommon.IsRange(this.Player.SlowFrame, -1, 1))                 // ? ショット中に低速・高速を切り替えた。
                {
                    this.Player.ShootRate = 0.0;
                }

                // ----

                if (this.Input.Shoot && this.Player.DeadFrame == 0)                 // プレイヤー攻撃
                {
                    this.Player.Shoot();
                }
                if (this.Input.Bomb && this.Player.DeadFrame == 0 && this.Player.BombFrame == 0 && 1 <= this.ZanBomb)                 // ボム使用
                {
                    this.ZanBomb--;
                    this.Player.BombFrame = 1;
                }

                // 当たり判定 reset
                {
                    this.PlayerCrashes.Clear();
                    this.GrazeCrashes.Clear();
                    this.EnemyCrashes.Clear();
                    this.ShotCrashes.Clear();
                }

                this.Player.Put当たり判定();

                // ====
                // 描画ここから
                // ====

                // Swap
                {
                    DDSubScreen tmp = this.Field;
                    this.Field      = this.Field_Last;
                    this.Field_Last = tmp;
                }

                using (this.Field.Section())                 // フィールド描画
                {
                    // Walls
                    {
                        int filledIndex = -1;

                        for (int index = 0; index < this.Walls.Count; index++)
                        {
                            Wall wall = this.Walls[index];

                            if (!wall.Draw())
                            {
                                this.Walls[index] = null;
                            }
                            else if (wall.Filled)
                            {
                                filledIndex = index;
                            }
                        }
                        for (int index = 0; index < filledIndex; index++)
                        {
                            this.Walls[index] = null;
                        }

                        this.Walls.RemoveAll(v => v == null);
                    }

                    RippleEffect.EachFrame(this.Field);

                    this.EL_AfterDrawWalls.ExecuteAllTask();

                    // Shots
                    {
                        for (int index = 0; index < this.Shots.Count; index++)
                        {
                            Shot shot = this.Shots[index];

                            if (!shot.Draw())
                            {
                                this.Shots[index] = null;
                            }
                        }
                        this.Shots.RemoveAll(v => v == null);
                    }

                    this.EL_AfterDrawShots.ExecuteAllTask();

                    if (this.Player.DeadFrame == 0)
                    {
                        this.Player.Draw();
                    }

                    this.EL_AfterDrawPlayer.ExecuteAllTask();

                    // Enemies
                    {
                        foreach (Enemy.Kind_e kind in new Enemy.Kind_e[]
                        {
                            Enemy.Kind_e.ENEMY,
                            Enemy.Kind_e.TAMA,
                            Enemy.Kind_e.ITEM,
                        })
                        {
                            for (int index = 0; index < this.Enemies.Count; index++)
                            {
                                Enemy enemy = this.Enemies[index];

                                if (enemy != null && enemy.Kind == kind)
                                {
                                    if (!enemy.Draw())
                                    {
                                        this.Enemies[index] = null;
                                    }
                                }
                            }
                        }
                        this.Enemies.RemoveAll(v => v == null);
                    }

                    this.EnemyEffects.ExecuteAllTask();
                    this.PlayerEffects.ExecuteAllTask();

                    // 当たり判定表示
                    // -- デバッグ用だが、ボタン設定に割り当てがあるので、常に使えるようにする。
                    if (1 <= DDInput.R.GetInput())
                    {
                        this.Draw当たり判定();
                    }

                    画面分割.EachFrame(this.Field);
                }

                {
                    DDUtils.Approach(ref this.BackgroundSlideRate, this.Player.Y * 1.0 / GameConsts.FIELD_H, 0.99);                     // HACK

                    D4Rect rect = DDUtils.AdjustRectExterior(
                        new D2Size(GameConsts.FIELD_W, GameConsts.FIELD_H),
                        new D4Rect(0, 0, DDConsts.Screen_W, DDConsts.Screen_H),
                        this.BackgroundSlideRate
                        //this.Player.Y * 1.0 / GameConsts.FIELD_H
                        );

                    DDDraw.DrawRect(this.Field.ToPicture(), rect);
                }

                {
                    const int MARGIN = 5;

                    DDDraw.SetBright(0, 0, 0);
                    DDDraw.DrawRect(
                        Ground.I.Picture.WhiteBox,
                        GameConsts.FIELD_L - MARGIN,
                        GameConsts.FIELD_T - MARGIN,
                        GameConsts.FIELD_W + MARGIN * 2,
                        GameConsts.FIELD_H + MARGIN * 2
                        );
                    DDDraw.Reset();
                }

                DX.GraphFilter(
                    DDGround.MainScreen.GetHandle(),
                    DX.DX_GRAPH_FILTER_GAUSS,
                    16,
                    SCommon.ToInt(500.0)
                    );

                DDCurtain.DrawCurtain(-0.2);

                DDDraw.DrawSimple(this.Field.ToPicture(), GameConsts.FIELD_L, GameConsts.FIELD_T);
                this.DrawStatus();
                this.SurfaceManager.Draw();

                // ====
                // 描画ここまで
                // ====

                foreach (Enemy enemy in this.Enemies.Iterate())
                {
                    if (!DDUtils.IsOut(new D2Point(enemy.X, enemy.Y), new D4Rect(0, 0, GameConsts.FIELD_W, GameConsts.FIELD_H)))                     // ? フィールド内
                    {
                        DDUtils.CountDown(ref enemy.TransFrame);
                        enemy.OnFieldFrame++;
                    }
                }

                this.当たり判定();

                if (this.AH_Grazed)
                {
                    if (
                        1 <= this.Player.BornFrame ||
                        1 <= this.Player.DeadFrame
                        )
                    {
                        // 登場中・死亡中は何もしない。
                    }
                    else
                    {
                        Ground.I.SE.SE_KASURI.Play();
                        this.Score++;
                    }
                }
                if (this.AH_PlayerCrashedFlag)
                {
                    if (
                        1 <= this.Player.BornFrame ||
                        1 <= this.Player.DeadFrame ||
                        1 <= this.Player.BombFrame
                        )
                    {
                        // 登場中・死亡中・ボム使用中は何もしない。
                    }
                    else
                    {
                        this.Player.DeadFrame = 1;                         // プレイヤー死亡
                        this.PlayerWasDead    = true;
                    }
                }

                if (Ground.I.HiScore < this.Score)
                {
                    if (Ground.I.HiScore + 10L < this.Score)
                    {
                        Ground.I.HiScore -= this.Score;
                        Ground.I.HiScore /= 2L;
                        Ground.I.HiScore += this.Score;
                    }
                    else
                    {
                        Ground.I.HiScore++;
                    }
                }

                f_ゴミ回収();

                this.Enemies.RemoveAll(v => v.HP == -1);
                this.Shots.RemoveAll(v => v.Vanished);

                DDEngine.EachFrame();

                // ★★★ ゲームループの終わり ★★★
            }

            DDUtils.Maxim(ref Ground.I.HiScore, this.Score);             // 確実な同期

            // ★★★★★ ステータス反映
            {
                this.Status.Score         = this.Score;
                this.Status.PlayerPower   = this.Player.Power;
                this.Status.PlayerZanki   = this.Zanki;
                this.Status.PlayerZanBomb = this.ZanBomb;
            }

            DDMain.KeepMainScreen();

            DDMusicUtils.Fade();
            DDCurtain.SetCurtain(60, -1.0);

            foreach (DDScene scene in DDSceneUtils.Create(120))
            {
                DDDraw.DrawRect(DDGround.KeptMainScreen.ToPicture(), 0, 0, DDConsts.Screen_W, DDConsts.Screen_H);
                DDEngine.EachFrame();
            }

            // ★★★ end of Perform() ★★★
        }
        public void AddNextSnapshot(TimeSpan lapTime, DriverInfo playerInfo, WeatherInfo weatherInfo, InputInfo inputInfo, SimulatorSourceInfo simulatorSource)
        {
            if ((playerInfo.InPits && playerInfo.Speed.InKph < 5) || lapTime < _nextSnapshotTime)
            {
                return;
            }

            _nextSnapshotTime = lapTime + _snapshotsIntervals;
            _snapshots.Add(new TimedTelemetrySnapshot(lapTime, playerInfo, weatherInfo, inputInfo, simulatorSource));
        }
Example #11
0
 public void MsgClick(InputInfo info)
 {
     Application.Quit();
 }
Example #12
0
        private void SyncronizeBase(InputInfo correctData, RaidaContext db)
        {
            //Save\Update members table
            correctData.MemberInfo.NewRows.ForEach(it =>
            {
                correctData.MemberInfo.Actual.Add(GetHash(new { login = it.Login, nick_name = it.NickName }));
                if (db.Members.Any(m => m.login.Equals(it.Login)))
                {
                    //UPDATE
                    Members member              = db.Members.First(m => m.login.Equals(it.Login));
                    member.nick_name            = it.NickName;
                    member.description_fragment = it.Descript;
                    member.last_use             = it.LastUse;
                    member.online         = it.Online;
                    member.photo_fragment = it.Photo;
                }
                else
                {
                    //INSERT NEW
                    Guid privateId = Guid.NewGuid();
                    while (db.Members.Any(memb => memb.private_id == privateId))
                    {
                        privateId = Guid.NewGuid();
                    }

                    Members member = new Members
                    {
                        private_id           = privateId,
                        login                = it.Login.Trim().ToLower(),
                        pass                 = it.Password,
                        nick_name            = it.NickName,
                        last_use             = it.LastUse,
                        description_fragment = it.Descript,
                        photo_fragment       = it.Photo,
                        kb_bandwidth_used    = 0,
                        online               = it.Online,
                    };
                    db.Members.Add(member);
                }
            });
            db.SaveChanges();


            //Save\Update groups table
            correctData.GroupInfo.NewRows.ForEach(it =>
            {
                correctData.GroupInfo.Actual.Add(GetHash(new { group_id = it.Id, group_name_part = it.Name, one_to_one = it.PeerToPeer }));
                Members owner = db.Members.First(m => m.login.Equals(it.Owner));
                if (db.Groups.Any(g => g.group_id == it.Id))
                {
                    Groups group          = db.Groups.First(g => g.group_id == it.Id);
                    group.group_name_part = it.Name;
                    group.one_to_one      = it.PeerToPeer;
                    group.photo_fragment  = it.Photo;
                    group.privated        = it.Privated;
                    group.owner           = owner;
                }
                else
                {
                    Groups newGroup = new Groups()
                    {
                        group_id        = it.Id,
                        group_name_part = it.Name,
                        owner           = owner,
                        photo_fragment  = it.Photo,
                        one_to_one      = it.PeerToPeer,
                        privated        = it.Privated
                    };
                    db.Groups.Add(newGroup);
                }
            });
            db.SaveChanges();

            //Save member in groups
            correctData.MinGInfo.NewRows.ForEach(it =>
            {
                correctData.MinGInfo.Actual.Add(GetHash(new { groupId = it.GroupId, login = it.Login }));
                if (db.Members.Any(m => m.login.Equals(it.Login) && db.Groups.Any(g => g.group_id == it.GroupId)))
                {
                    Groups group   = db.Groups.First(gr => gr.group_id == it.GroupId);
                    Members member = db.Members.First(m => m.login.Equals(it.Login));

                    if (!db.MemberInGroup.Any(mig => mig.member.Equals(member) && mig.group.Equals(group))) //Find duplicate
                    {
                        int newId = 0;
                        if (db.MemberInGroup.Any())
                        {
                            newId = db.MemberInGroup.OrderByDescending(mig => mig.Id).FirstOrDefault().Id + 1;
                        }

                        MemberInGroup mg = new MemberInGroup
                        {
                            Id     = newId,
                            group  = group,
                            member = member
                        };
                        db.MemberInGroup.Add(mg);
                    }
                }
            });
            db.SaveChanges();

            //Remove not actual data in tables
            db.Members.ForEachAsync(it =>
            {
                if (!correctData.MemberInfo.Actual.Contains(GetHash(it)))
                {
                    db.Members.Remove(it);
                }
            });

            db.Groups.ForEachAsync(it =>
            {
                if (!correctData.GroupInfo.Actual.Contains(GetHash(it)))
                {
                    db.Groups.Remove(it);
                }
            });

            db.MemberInGroup.ForEachAsync(it =>
            {
                if (!correctData.MinGInfo.Actual.Contains(GetHash(it)))
                {
                    db.MemberInGroup.Remove(it);
                }
            });
            db.SaveChangesAsync();
        }
Example #13
0
 public void Reset()
 {
     InputInfo.ResetChange();
 }
Example #14
0
        private static IElement NewAction(XmlNode xmlNode, IElement parent = null)
        {
            IElement   element    = null;
            IElement   ne         = null; // child elements
            XmlElement importNode = (xmlNode as XmlElement);

            if (xmlNode.Name == "Action")
            {
                switch (importNode.GetAttribute("Type"))
                {
                case "AppTree":
                    AppTree appTree = new AppTree(Globals.EventAggregator)
                    {
                        ApplicationVariableBase = importNode.GetAttribute("ApplicationVariableBase"),
                        PackageVariableBase     = importNode.GetAttribute("PackageVariableBase"),
                        Title     = importNode.GetAttribute("Title"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("CenterTitle")))
                    {
                        appTree.CenterTitle = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("CenterTitle")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Size")))
                    {
                        appTree.Size = importNode.GetAttribute("Size");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Expanded")))
                    {
                        appTree.Expanded = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Expanded")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        appTree.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowCancel")))
                    {
                        appTree.ShowCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowCancel")));
                    }

                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, appTree);

                        /* This is handled by the only valid subelement in AppTree (SoftwareSets)
                         * if(ne is IChildElement)
                         * {
                         *  appTree.SubChildren.Add(ne as IChildElement);
                         * }
                         */
                    }
                    element = appTree;
                    break;

                case "DefaultValues":
                    DefaultValues defaultValues = new DefaultValues(Globals.EventAggregator)
                    {
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ValueTypes")))
                    {
                        string[] defaultValueTypes = importNode.GetAttribute("ValueTypes").Split(',');
                        defaultValues.ValueTypeList.Where(x => x.Name == "All").First().IsSelected = false;
                        foreach (string defaultValueType in defaultValueTypes)
                        {
                            if (defaultValues.ValueTypeList.Where(x => x.Name == defaultValueType).Count() > 0)
                            {
                                defaultValues.ValueTypeList.Where(x => x.Name == defaultValueType).First().IsSelected = true;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowProgress")))
                    {
                        defaultValues.ShowProgress = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowProgress")));
                    }
                    element = defaultValues;
                    break;

                case "ErrorInfo":
                    ErrorInfo errorInfo = new ErrorInfo(Globals.EventAggregator)
                    {
                        Image     = importNode.GetAttribute("Image"),
                        InfoImage = importNode.GetAttribute("InfoImage"),
                        Name      = importNode.GetAttribute("Name"),
                        Title     = importNode.GetAttribute("Title"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("CenterTitle")))
                    {
                        errorInfo.CenterTitle = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("CenterTitle")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        errorInfo.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowCancel")))
                    {
                        errorInfo.ShowCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowCancel")));
                    }
                    element = errorInfo;
                    break;

                case "ExternalCall":
                    ExternalCall externalCall = new ExternalCall(Globals.EventAggregator)
                    {
                        ExitCodeVariable = importNode.GetAttribute("ExitCodeVariable"),
                        Title            = importNode.GetAttribute("Title"),
                        Condition        = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ExitCodeVariable")))
                    {
                        externalCall.ExitCodeVariable = importNode.GetAttribute("ExitCodeVariable");
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        externalCall.Content = CDATARemover(importNode.InnerXml);
                    }
                    element = externalCall;
                    break;

                case "FileRead":
                    FileRead fileRead = new FileRead(Globals.EventAggregator)
                    {
                        FileName  = importNode.GetAttribute("Filename"),
                        Variable  = importNode.GetAttribute("Variable"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DeleteLine")))
                    {
                        fileRead.DeleteLine = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DeleteLine")));
                    }
                    element = fileRead;
                    break;

                case "Info":
                    Info info = new Info(Globals.EventAggregator)
                    {
                        Image     = importNode.GetAttribute("Image"),
                        InfoImage = importNode.GetAttribute("InfoImage"),
                        Name      = importNode.GetAttribute("Name"),
                        Title     = importNode.GetAttribute("Title"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        info.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowCancel")))
                    {
                        info.ShowCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowCancel")));
                    }
                    if (int.TryParse(importNode.GetAttribute("Timeout"), out int infoTimeout))
                    {
                        info.Timeout = infoTimeout;
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("TimeoutAction")))
                    {
                        info.TimeoutAction = importNode.GetAttribute("TimeoutAction");
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        info.Content = CDATARemover(importNode.InnerXml);
                    }
                    element = info;
                    break;

                case "InfoFullScreen":
                    InfoFullScreen infoFullScreen = new InfoFullScreen(Globals.EventAggregator)
                    {
                        Image = importNode.GetAttribute("Image")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("BackgroundColor")))
                    {
                        infoFullScreen.BackgroundColor = ColorConverter(importNode.GetAttribute("BackgroundColor"));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("TextColor")))
                    {
                        infoFullScreen.TextColor = ColorConverter(importNode.GetAttribute("TextColor"));
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        infoFullScreen.Content = CDATARemover(importNode.InnerXml);
                    }
                    break;

                case "Input":
                    Input input = new Input(Globals.EventAggregator)
                    {
                        Name      = importNode.GetAttribute("Name"),
                        Title     = importNode.GetAttribute("Title"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Size")))
                    {
                        input.Size = importNode.GetAttribute("Size");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        input.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowCancel")))
                    {
                        input.ShowCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowCancel")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("CenterTitle")))
                    {
                        input.CenterTitle = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("CenterTitle")));
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, input);
                        if (ne is IChildElement)
                        {
                            input.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = input;
                    break;

                case "Preflight":
                    Preflight preflight = new Preflight(Globals.EventAggregator)
                    {
                        Title     = importNode.GetAttribute("Title"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Size")))
                    {
                        preflight.Size = importNode.GetAttribute("Size");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        preflight.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowCancel")))
                    {
                        preflight.ShowCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowCancel")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("CenterTitle")))
                    {
                        preflight.CenterTitle = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("CenterTitle")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowOnFailureOnly")))
                    {
                        preflight.CenterTitle = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowOnFailureOnly")));
                    }
                    if (int.TryParse(importNode.GetAttribute("Timeout"), out int preflightTimeout))
                    {
                        preflight.Timeout = preflightTimeout;
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("TimeoutAction")))
                    {
                        preflight.TimeoutAction = importNode.GetAttribute("TimeoutAction");
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, preflight);
                        if (ne is IChildElement)
                        {
                            preflight.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = preflight;
                    break;

                case "RandomString":
                    RandomString randomString = new RandomString(Globals.EventAggregator)
                    {
                        Variable  = importNode.GetAttribute("Variable"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("AllowedChars")))
                    {
                        randomString.AllowedChars = importNode.GetAttribute("AllowedChars");
                    }
                    if (int.TryParse(importNode.GetAttribute("Length"), out int randomLength))
                    {
                        randomString.Length = randomLength;
                    }
                    element = randomString;
                    break;

                case "RegRead":
                    RegRead regRead = new RegRead(Globals.EventAggregator)
                    {
                        Default   = importNode.GetAttribute("Default"),
                        Key       = importNode.GetAttribute("Key"),
                        Variable  = importNode.GetAttribute("Variable"),
                        Value     = importNode.GetAttribute("Value"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Reg64")))
                    {
                        regRead.Reg64 = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Reg64")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Hive")))
                    {
                        regRead.Hive = importNode.GetAttribute("Hive");
                    }
                    element = regRead;
                    break;

                case "RegWrite":
                    RegWrite regWrite = new RegWrite(Globals.EventAggregator)
                    {
                        Key       = importNode.GetAttribute("Key"),
                        Value     = importNode.GetAttribute("Value"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Reg64")))
                    {
                        regWrite.Reg64 = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Reg64")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Type")))
                    {
                        regWrite.ValueType = importNode.GetAttribute("Type");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Hive")))
                    {
                        regWrite.Hive = importNode.GetAttribute("Hive");
                    }
                    element = regWrite;
                    break;

                case "SaveItems":
                    SaveItems saveItems = new SaveItems(Globals.EventAggregator)
                    {
                        Items     = importNode.GetAttribute("Items"),
                        Path      = importNode.GetAttribute("Path"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    element = saveItems;
                    break;

                case "SoftwareDiscovery":
                    SoftwareDiscovery softwareDiscovery = new SoftwareDiscovery(Globals.EventAggregator)
                    {
                        Condition = importNode.GetAttribute("Condition"),
                    };
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, softwareDiscovery);
                        if (ne is IChildElement)
                        {
                            softwareDiscovery.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = softwareDiscovery;
                    break;

                case "Switch":
                    Switch switchClass = new Switch(Globals.EventAggregator)
                    {
                        OnValue   = importNode.GetAttribute("OnValue"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DontEval")))
                    {
                        switchClass.DontEval = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DontEval")));
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, switchClass);
                        if (ne is IChildElement)
                        {
                            switchClass.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = switchClass;
                    break;

                case "TSVar":
                    TSVar tsVar = new TSVar(Globals.EventAggregator)
                    {
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DontEval")))
                    {
                        tsVar.DontEval = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DontEval")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Name")))
                    {
                        tsVar.Variable = importNode.GetAttribute("Name");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Variable")))
                    {
                        tsVar.Variable = importNode.GetAttribute("Variable");
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        tsVar.Content = CDATARemover(importNode.InnerXml);
                    }
                    element = tsVar;
                    break;

                case "TSVarList":
                    TSVarList tsVarList = new TSVarList(Globals.EventAggregator)
                    {
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ApplicationVariableBase")))
                    {
                        tsVarList.ApplicationVariableBase = importNode.GetAttribute("ApplicationVariableBase");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("PackageVariableBase")))
                    {
                        tsVarList.PackageVariableBase = importNode.GetAttribute("PackageVariableBase");
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, tsVarList);
                        if (ne is IChildElement)
                        {
                            tsVarList.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = tsVarList;
                    break;

                case "UserAuth":
                    UserAuth userAuth = new UserAuth(Globals.EventAggregator)
                    {
                        Attributes       = importNode.GetAttribute("Attributes"),
                        Domain           = importNode.GetAttribute("Domain"),
                        DomainController = importNode.GetAttribute("DomainController"),
                        Group            = importNode.GetAttribute("Group"),
                        Title            = importNode.GetAttribute("Title")
                    };
                    if (int.TryParse(importNode.GetAttribute("MaxRetryCount"), out int uaMaxRetryCount))
                    {
                        userAuth.MaxRetryCount = uaMaxRetryCount;
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DisableCancel")))
                    {
                        userAuth.DisableCancel = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DisableCancel")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DoNotFallback")))
                    {
                        userAuth.DoNotFallback = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DoNotFallback")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("GetGroups")))
                    {
                        userAuth.GetGroups = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("GetGroups")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ShowBack")))
                    {
                        userAuth.ShowBack = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ShowBack")));
                    }
                    element = userAuth;
                    break;

                case "Vars":
                    Vars vars = new Vars(Globals.EventAggregator)
                    {
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Direction")))
                    {
                        vars.Direction = importNode.GetAttribute("Direction");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Filename")))
                    {
                        vars.Filename = importNode.GetAttribute("Filename");
                    }
                    element = vars;
                    break;

                case "WMIRead":
                    WMIRead wmiRead = new WMIRead(Globals.EventAggregator)
                    {
                        Class        = importNode.GetAttribute("Class"),
                        Default      = importNode.GetAttribute("Default"),
                        KeyQualifier = importNode.GetAttribute("KeyQualifier"),
                        Property     = importNode.GetAttribute("Property"),
                        Query        = importNode.GetAttribute("Query"),
                        Variable     = importNode.GetAttribute("Variable"),
                        Condition    = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Namespace")))
                    {
                        wmiRead.Namespace = importNode.GetAttribute("Namespace");
                    }
                    element = wmiRead;
                    break;

                case "WMIWrite":
                    WMIWrite wmiWrite = new WMIWrite(Globals.EventAggregator)
                    {
                        Class     = importNode.GetAttribute("Class"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Namespace")))
                    {
                        wmiWrite.Namespace = importNode.GetAttribute("Namespace");
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, wmiWrite);
                        if (ne is IChildElement)
                        {
                            wmiWrite.SubChildren.Add(ne as IChildElement);
                        }
                    }
                    element = wmiWrite;
                    break;
                }
            }
            else
            {
                switch (xmlNode.Name)
                {
                case "ActionGroup":
                    ActionGroup actionGroup = new ActionGroup(Globals.EventAggregator)
                    {
                        Name      = importNode.GetAttribute("Name"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x);
                        actionGroup.Children.Add(ne);
                    }
                    element = actionGroup;
                    break;

                case "Case":
                    Case caseClass = new Case(parent)
                    {
                        RegEx     = importNode.GetAttribute("RegEx"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("CaseInsensitive")))
                    {
                        caseClass.CaseInsensitive = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("CaseInsensitive")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DontEval")))
                    {
                        caseClass.DontEval = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DontEval")));
                    }
                    element = caseClass;
                    break;

                case "Check":
                    Check check = new Check(parent as Preflight)
                    {
                        CheckCondition   = importNode.GetAttribute("CheckCondition"),
                        Description      = importNode.GetAttribute("Description"),
                        ErrorDescription = importNode.GetAttribute("ErrorDescription"),
                        Text             = importNode.GetAttribute("Text"),
                        WarnCondition    = importNode.GetAttribute("WarnCondition"),
                        WarnDescription  = importNode.GetAttribute("WarnDescription"),
                        Condition        = importNode.GetAttribute("Condition")
                    };
                    element = check;
                    break;

                case "Choice":
                    Choice choice = new Choice(parent)
                    {
                        Option         = importNode.GetAttribute("Option"),
                        Value          = importNode.GetAttribute("Value"),
                        AlternateValue = importNode.GetAttribute("AlternateValue"),
                        Condition      = importNode.GetAttribute("Condition")
                    };
                    element = choice;
                    break;

                case "ChoiceList":
                    ChoiceList choiceList = new ChoiceList(parent)
                    {
                        OptionList         = importNode.GetAttribute("OptionList"),
                        ValueList          = importNode.GetAttribute("ValueList"),
                        AlternateValueList = importNode.GetAttribute("AlternateValueList"),
                        Condition          = importNode.GetAttribute("Condition")
                    };
                    element = choiceList;
                    break;

                case "Field":
                    Field field = new Field()
                    {
                        Name     = importNode.GetAttribute("Name"),
                        Hint     = importNode.GetAttribute("Hint"),
                        List     = importNode.GetAttribute("List"),
                        Prompt   = importNode.GetAttribute("Prompt"),
                        Question = importNode.GetAttribute("Question"),
                        RegEx    = importNode.GetAttribute("RegEx")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ReadOnly")))
                    {
                        field.ReadOnly = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ReadOnly")));
                    }
                    element = field;
                    break;

                case "InputCheckbox":
                case "CheckboxInput":
                    InputCheckbox inputCheckbox = new InputCheckbox(parent as Input)
                    {
                        CheckedValue   = importNode.GetAttribute("CheckedValue"),
                        Default        = importNode.GetAttribute("Default"),
                        Question       = importNode.GetAttribute("Question"),
                        Variable       = importNode.GetAttribute("Variable"),
                        UncheckedValue = importNode.GetAttribute("UncheckedValue"),
                        Condition      = importNode.GetAttribute("Condition")
                    };
                    element = inputCheckbox;
                    break;

                case "InputChoice":
                case "ChoiceInput":
                    InputChoice inputChoice = new InputChoice(parent as Input)
                    {
                        AlternateVariable = importNode.GetAttribute("AlternateValue"),
                        Default           = importNode.GetAttribute("Default"),
                        Question          = importNode.GetAttribute("Question"),
                        Variable          = importNode.GetAttribute("Variable"),
                        Condition         = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("AutoComplete")))
                    {
                        inputChoice.AutoComplete = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("AutoComplete")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Required")))
                    {
                        inputChoice.Required = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Required")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Sort")))
                    {
                        inputChoice.Sort = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Sort")));
                    }
                    if (int.TryParse(importNode.GetAttribute("DropDownSize"), out int inputChoiceDropDownSize))
                    {
                        inputChoice.DropDownSize = inputChoiceDropDownSize;
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, inputChoice);
                        inputChoice.SubChildren.Add(ne as IChildElement);
                    }
                    element = inputChoice;
                    break;

                case "InputInfo":
                case "InfoInput":
                    InputInfo inputInfo = new InputInfo(parent as Input)
                    {
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Color")))
                    {
                        inputInfo.Color = ColorConverter(importNode.GetAttribute("Color"));
                    }
                    if (int.TryParse(importNode.GetAttribute("DropDownSize"), out int inputInfoNumberOfLines))
                    {
                        inputInfo.NumberOfLines = inputInfoNumberOfLines;
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        inputInfo.Content = CDATARemover(importNode.InnerXml);
                    }
                    element = inputInfo;
                    break;

                case "InputText":
                case "TextInput":
                    InputText inputText = new InputText(parent as Input)
                    {
                        Default   = importNode.GetAttribute("Default"),
                        Hint      = importNode.GetAttribute("Hint"),
                        Prompt    = importNode.GetAttribute("Prompt"),
                        Question  = importNode.GetAttribute("Question"),
                        RegEx     = importNode.GetAttribute("RegEx"),
                        Variable  = importNode.GetAttribute("Variable"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ADValidate")))
                    {
                        inputText.ADValidate = importNode.GetAttribute("ADValidate");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ForceCase")))
                    {
                        inputText.ForceCase = importNode.GetAttribute("ForceCase");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("HScroll")))
                    {
                        inputText.HScroll = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("HScroll")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Password")))
                    {
                        inputText.Password = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Password")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("ReadOnly")))
                    {
                        inputText.ReadOnly = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("ReadOnly")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Required")))
                    {
                        inputText.Required = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Required")));
                    }
                    element = inputText;
                    break;

                case "Match":
                    Match match = new Match(parent as IParentElement)
                    {
                        DisplayName = importNode.GetAttribute("DisplayName"),
                        Variable    = importNode.GetAttribute("Variable"),
                        Version     = importNode.GetAttribute("Version"),
                        Condition   = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("VersionOperator")))
                    {
                        match.VersionOperator = importNode.GetAttribute("VersionOperator");
                    }
                    element = match;
                    break;

                case "Property":
                    Property property = new Property(parent)
                    {
                        Name      = importNode.GetAttribute("Name"),
                        Value     = importNode.GetAttribute("Value"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Type")))
                    {
                        property.Type = importNode.GetAttribute("Type");
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Key")))
                    {
                        property.Key = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Key")));
                    }
                    element = property;
                    break;

                case "Set":
                    Set set = new Set(parent)
                    {
                        Name      = importNode.GetAttribute("Name"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, set);
                        set.SubChildren.Add(ne as IChildElement);
                    }
                    element = set;
                    break;

                case "SoftwareGroup":
                    SoftwareGroup softwareGroup = new SoftwareGroup(parent)
                    {
                        Id        = importNode.GetAttribute("Id"),
                        Label     = importNode.GetAttribute("Label"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Default")))
                    {
                        softwareGroup.Default = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Default")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Required")))
                    {
                        softwareGroup.Required = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Required")));
                    }
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, softwareGroup);
                        softwareGroup.SubChildren.Add(ne as IChildElement);
                    }
                    element = softwareGroup;
                    break;

                case "SoftwareListRef":
                    SoftwareListRef softwareListRef = new SoftwareListRef(parent as IParentElement)
                    {
                        Id        = importNode.GetAttribute("Id"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    element = softwareListRef;
                    break;

                case "SoftwareRef":
                    SoftwareRef softwareRef = new SoftwareRef(parent)
                    {
                        Id        = importNode.GetAttribute("Id"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Hidden")))
                    {
                        softwareRef.Hidden = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Hidden")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Default")))
                    {
                        softwareRef.Default = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Default")));
                    }
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("Required")))
                    {
                        softwareRef.Required = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("Required")));
                    }
                    element = softwareRef;
                    break;

                case "SoftwareSets":
                    AppTree at = parent as AppTree;
                    ObservableCollection <IChildElement> e = new ObservableCollection <IChildElement>();
                    foreach (XmlNode x in importNode.ChildNodes)
                    {
                        ne = NewAction(x, at);
                        e.Add(ne as IChildElement);
                    }
                    at.SubChildren = e;
                    element        = null;
                    break;

                case "Text":
                    Text text = new Text(parent as IParentElement)
                    {
                        Type      = importNode.GetAttribute("Type"),
                        Value     = importNode.GetAttribute("Value"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    element = text;
                    break;

                case "Variable":
                    Variable variable = new Variable(parent)
                    {
                        Name      = importNode.GetAttribute("Name"),
                        Condition = importNode.GetAttribute("Condition")
                    };
                    if (!string.IsNullOrEmpty(importNode.GetAttribute("DontEval")))
                    {
                        variable.DontEval = Convert.ToBoolean(StringToBoolString(importNode.GetAttribute("DontEval")));
                    }
                    if (!string.IsNullOrEmpty(importNode.InnerXml))
                    {
                        variable.Content = CDATARemover(importNode.InnerXml);
                    }
                    element = variable;
                    break;
                }
            }
            return(element);
        }
Example #15
0
 private void Awake()
 {
     _inputInfo      = GetComponent <InputInfo>();
     _animController = GetComponent <CharacterAnimController>();
     _transform      = transform;
 }
Example #16
0
        public static UModule Create(string moduleName, int id)
        {
            Debug.Log($"Attempting to create {moduleName}{id}");
            // Load the module's prefab into the scene
            var        prefab = GetPrefab(moduleName);
            GameObject gameObject;

            if (prefab != null)
            {
                gameObject = Instantiate(GetPrefab(moduleName));
            }
            // if there's no custom prefab, create a new object
            else
            {
                UnityEngine.Debug.Log($"Attempting to instantiate module {moduleName} without custom prefab.");
                gameObject = new GameObject();
                // and add the corresponding UModule component
                if (!Application.PluginModules.Keys.Contains(moduleName))
                {
                    UnityEngine.Debug.Log($"Attempt to instantiate backend for {moduleName} module failed. Does {moduleName}.cs exist?");
                }

                Type moduleComponent = Application.PluginModules[moduleName];
                gameObject.AddComponent(moduleComponent);
                if (moduleComponent.IsSubclassOf(typeof(VFXModule)))
                {
                    var visualEffect = gameObject.AddComponent <VisualEffect>();
                    visualEffect.visualEffectAsset = Resources.Load <VisualEffectAsset>(moduleName + "Graph");
                    var propertyBinder = gameObject.AddComponent <VFXPropertyBinder>();
                    propertyBinder.AddPropertyBinder <PointCloudBinder>();
                }
            }
            var instanceName = moduleName + "Instance" + id;

            gameObject.name = instanceName;

            // set properties
            var moduleInstance = Instances[id] = gameObject.GetComponent <UModule>();

            moduleInstance.ModuleType      = moduleName;
            moduleInstance.InstanceName    = instanceName;
            moduleInstance.Id              = id;
            moduleInstance.InstanceAddress = "/" + moduleName + "/" + id;

            Type moduleType = null;

#if UNITY_EDITOR
            // If we're in the editor, try looking for the module in unpackaged code
            Assembly scriptingAssembly = AppDomain.CurrentDomain.GetAssemblies()
                                         .SingleOrDefault(a => a.FullName.Contains("Assembly-CSharp,"));
            moduleType = scriptingAssembly?.GetTypes()
                         .SingleOrDefault(t => t.Name == moduleName);
#endif
            // Otherwise find the module in assemblies loaded in plugins
            if (moduleType == null)
            {
                moduleType = Application.PluginModules[moduleName];
            }

            // Get properties marked with URack attributes
            var inputProperties = moduleType.GetProperties()
                                  .Where(p => p.GetCustomAttribute <InputAttribute>() != null).ToArray();
            var outputProperties = moduleType.GetProperties()
                                   .Where(p => p.GetCustomAttribute <OutputAttribute>() != null).ToList();

            // Create a voltage representation of each input
            foreach (var inputProperty in inputProperties)
            {
                if (inputProperty.PropertyType == typeof(PointCloud))
                {
                    continue;
                }

                var inputAttribute = inputProperty.GetCustomAttribute <InputAttribute>();
                var inputInfo      = new InputInfo(inputProperty, inputAttribute);
                moduleInstance.Inputs.Add(inputInfo.Property.Name, inputInfo);

                // Instantiate the voltage vector
                moduleInstance.Voltages[inputInfo] = new Vector2(0, 0);
            }

            // Populate a list of outputs to update to
            outputProperties.ForEach(o => moduleInstance.Outputs.Add(new OutputInfo(o)));

            // This list here runs each method added to it on every frame.
            moduleInstance.RuntimeUpdates.Add(() => typeof(UModule).GetMethod("ValueUpdate").Invoke(moduleInstance, new object[] {  }));
            moduleInstance.RuntimeUpdates.Add(() => typeof(UModule).GetMethod("ConnectionUpdate").Invoke(moduleInstance, new object[] {  }));
            moduleInstance.RuntimeUpdates.Add(() => typeof(UModule).GetMethod("OutputUpdate").Invoke(moduleInstance, new object[] {  }));

            // After creating a module, we should query if the VCV patch has
            // stored any connections for it
            Osc.Server.Send <string>("QueryConnections", moduleInstance.InstanceAddress);

            if (!PatchedTypes.Contains(moduleType))
            {
                PatchedTypes.Add(moduleType);
            }

            return(moduleInstance);
        }
Example #17
0
        private static string CreateChart(InputInfo inputInfo)
        {
            const decimal tableSize   = 40;
            const decimal pointSize   = 0.25m;
            var           intSize     = Math.Round(tableSize * 17 / 20, 2);
            const int     maxLines    = 11; // - 1 for actual number of lines
            const string  chartEnd    = "</div>";
            var           legendAlign = inputInfo.ChartType.Equals("ClimbTime") ? 2.5 : 75;

            var chartStart =
                $@"<div style=""position:relative;width:{tableSize}rem;height:{tableSize}rem;background:#f0f0f0;border:solid;margin:1rem auto"">
<div style=""position:absolute;left:{Math.Round(tableSize / 10, 2)}rem;top:{Math.Round(tableSize / 20, 2)}rem;width:{intSize}rem;height:{intSize}rem;background:white;border:solid;overflow:hidden"">";

            var chartLines = new StringBuilder();

            for (var lineNum = 1; lineNum < maxLines; lineNum++)
            {
                // Originating from Y Lines
                chartLines.Append(
                    $@"<div style=""position:absolute;top:{Math.Round(intSize / maxLines * lineNum, 2)}rem; width:{intSize}rem;border-bottom:dashed 2px lightgray;""></div>");
                // X Lines
                chartLines.Append(
                    $@"<div style=""position:absolute;height:{intSize}rem;left:{Math.Round(intSize / maxLines * lineNum, 2)}rem;border-right:dashed 2px lightgray;""></div>");
            }

            // Max code alt
            float maxAltMil = inputInfo.RawDataMil[inputInfo.RawDataMil.Count - 1][0] / 1000f,
                  maxAltWep = inputInfo.RawDataWep.Count != 0 ? inputInfo.RawDataWep[inputInfo.RawDataWep.Count - 1][0] / 1000f : 0;
            var maxAlt      = Math.Ceiling(maxAltMil > maxAltWep ? maxAltMil : maxAltWep);

            maxAlt = maxAlt > 10 ? maxAlt : 10;
            // Max 10 Alt
            //const double maxAlt = 10;

            var chartUnits = new StringBuilder();

            for (var lineNum = maxLines; lineNum > 0; lineNum--)
            {
                // Y Values. Top to bottom
                chartUnits.Append(
                    $@"<div style=""position:absolute;top:{Math.Round((double) intSize / maxLines * (lineNum + 0.5), 2)}rem;width:{Math.Round(tableSize / 12, 2)}rem"" align=""right"">{Math.Round(maxAlt / (maxLines - 1) * (maxLines - lineNum), 1)}</div>");

                // X Values. Left to Right
                chartUnits.Append(
                    $@"<div style=""position:absolute;top:{Math.Round(intSize + tableSize * 3 / 40 - 0.3M, 2)}rem;left:{Math.Round((double) intSize / maxLines * lineNum + 0.6, 2)}rem;width:{Math.Round(tableSize / lineNum, 2)}"" align=""center"">{Math.Round(inputInfo.MinX + (inputInfo.MaxX - inputInfo.MinX) / (maxLines - 1) * (lineNum - 1))}</div>");
            }

            var penBox =
                $@"<div style=""position:absolute;width:{Math.Round((1 - 1 / (double) (maxLines - 1)) * 100, 2)}%;height:{Math.Round((1 - 1 / (decimal) (maxLines - 1)) * 100, 2)}%;bottom:0;left:0"">";

            var penCoords = new StringBuilder();
            var penLines  = new StringBuilder();
            var penLegend = new StringBuilder();
            var prevPoint = new[] { 0d, 0d };

            // Mil list first
            for (var coordinate = 0; coordinate < inputInfo.RawDataMil.Count; coordinate++)
            {
                /* Vertical (bottom) Offset: (1 - boxSize / 2 / intSize )
                 * Experimentally Determined.
                 * Reduced by half the height (aka length) of the box.
                 * Then converted to % of box.
                 */
                var boxPointX = Math.Round((inputInfo.RawDataMil[coordinate][1] - inputInfo.MinX) / (inputInfo.MaxX - inputInfo.MinX) * 100, 2);
                var boxPointY = Math.Round(inputInfo.RawDataMil[coordinate][0] / maxAlt / 1000 * 100, 2);
                if (coordinate != 0)
                {
                    var lineLength =
                        Math.Round(Math.Sqrt(Math.Pow(prevPoint[0] - boxPointX, 2) +
                                             Math.Pow(prevPoint[1] - boxPointY, 2)));
                    var rotate = Math.Round(Math.Atan((prevPoint[0] - boxPointX) / (prevPoint[1] - boxPointY)), 2);
                    // Lines
                    penLines.Append(
                        $@"<div style=""position:absolute;transform:rotate({rotate}rad);left:{(boxPointX + prevPoint[0]) / 2}%;bottom:{(boxPointY + prevPoint[1]) / 2 - lineLength / 2 + 1}%;height:{lineLength}%;border-right:solid #{ColourValues[0]}""></div>");
                }

                prevPoint[0] = boxPointX;
                prevPoint[1] = boxPointY;

                // Points
                penCoords.Append(
                    $@"<div style=""position:absolute;left:{boxPointX - (double) pointSize}%;bottom:{boxPointY}%;width:{pointSize}rem;height:{pointSize}rem;border:solid #{ColourValues[0]};border-radius:50%;background:white;""></div>");
            }
            // Mil Legend
            penLegend.Append(
                $@"<div style=""position:relative;padding:0.2rem;border:solid #{ColourValues[0]};width:20%;top:1%;margin:0 0 0 {legendAlign}%;background:white;text-align:center"">100%</div>");

            if (inputInfo.RawDataWep.Count != 0)
            {
                prevPoint = new[] { 0d, 0d };
                // WEP List
                for (var coordinate = 0; coordinate < inputInfo.RawDataWep.Count; coordinate++)
                {
                    var boxPointX = Math.Round((inputInfo.RawDataWep[coordinate][1] - inputInfo.MinX) / (inputInfo.MaxX - inputInfo.MinX) * 100, 2);
                    var boxPointY = Math.Round(inputInfo.RawDataWep[coordinate][0] / maxAlt / 1000 * 100, 2);
                    if (coordinate != 0)
                    {
                        var lineLength =
                            Math.Round(Math.Sqrt(Math.Pow(prevPoint[0] - boxPointX, 2) +
                                                 Math.Pow(prevPoint[1] - boxPointY, 2)));
                        var rotate = Math.Round(Math.Atan((prevPoint[0] - boxPointX) / (prevPoint[1] - boxPointY)), 2);
                        // Lines
                        penLines.Append(
                            $@"<div style=""position:absolute;transform:rotate({rotate}rad);left:{(boxPointX + prevPoint[0]) / 2}%;bottom:{(boxPointY + prevPoint[1]) / 2 - lineLength / 2 + 1}%;height:{lineLength}%;border-right:dashed #{ColourValues[0]}""></div>");
                    }

                    prevPoint[0] = boxPointX;
                    prevPoint[1] = boxPointY;

                    // Points
                    penCoords.Append(
                        $@"<div style=""position:absolute;left:{boxPointX - (double) pointSize}%;bottom:{boxPointY}%;width:{pointSize}rem;height:{pointSize}rem;border:solid #{ColourValues[0]};border-radius:50%;background:white;""></div>");
                }
                // WEP Legend
                penLegend.Append(
                    $@"<div style=""position:relative;padding:0.2rem;border:dashed #{ColourValues[0]};width:20%;top:1%;margin:0 0 0 {legendAlign}%;background:white;text-align:center"">WEP</div>");
            }

            // First is X Axis, second is Y Axis.
            var chartWords = $@"<b><div style=""position:absolute;width:100%"" align=""center"">{inputInfo.Title}</div>
<div style=""position:absolute;width:100%;top:{tableSize - 1.5M}rem"" align=""center"">{inputInfo.XAxis}</div>
<div style=""transform:rotate(90deg);position:relative;left:-{tableSize - 1.5M}rem;height:100%;"" align=""center"">{inputInfo.YAxis}</div></b>";

            // TODO: Shift this off to a separate function.
            // To prevent people from saying my poor chart is bugged.
            const string chartWarning =
                @"<div style=""position:relative;text-align:center;font-weight:bold;top:0.5rem"">Colors indicated in the legend that do not appear in the graph may be hidden behind another line.</div>";

            var exportFile =
                $@"<div class=""mw-customtoggle-performance_{inputInfo.ChartType}"" style=""text-align:center;width:auto;overflow:auto;border:solid orange;border-radius:0.625rem;background:mistyrose"">
<span style=""font-size:1.2rem;font-style:italic;font-weight:bold"">{inputInfo.Title} Chart</span>
</div>
<div class=""mw-collapsible"" id=""mw-customcollapsible-performance_{inputInfo.ChartType}"" style=""width:99%;"">
<div class=""mw-collapsible-content"" style=""border:solid lightgray;background:white;margin-left:1%;padding:0 1%;overflow:auto"">
{chartWarning}
{chartStart}
{chartLines}
{penBox}
{penLines}
{penCoords}
{chartEnd}
{penLegend}
{chartEnd}
{chartWords}
{chartUnits}
{chartEnd}
</div>
</div>
";

            return(exportFile);
        }
Example #18
0
    private void UpdateDownState()
    {
        Vector2 tapDown;
        bool isDown = TapDown( out tapDown );
        currTouch.time = Time.time;
        if( isDown ) {
            if ( ( tapDown - currTouch.pos ).magnitude > deadZone ) {
                touchState = TouchState.Dragging;
                lastTouch = currTouch;
            }
        } else {
            // tap up
            if( lastTouch.time != 0 && currTouch.time - lastTouch.time < doubleTapTimeDelta ) {
                SendDoubleTapMessage( MakeHitInputEvent() );
            } else {
                SendSingleTapMessage( MakeHitInputEvent() );
            }
            SendTapUpMessage( MakeHitInputEvent() );
            lastTouch = currTouch;

            touchState = TouchState.TapUp;
            currTouch.pos = Vector3.zero;
            SendTapMessage( MakeInputEvent() );
        }
    }
Example #19
0
 public static extern bool GetLastInputInfo(ref InputInfo inputInfo);
Example #20
0
        public void SetAnimParam(InputInfo handInput)
        {
            ClearAnimParam();
            if (handInput.directionEnum != InputDir.Middle)
            {
                int InputNum = (int)handInput.directionEnum;
                //将逻辑枚举拆分成
                switch (handInput.GetHoriEnum())
                {
                case InputDir.Left:
                    ActionCtrl.SetBool("Dir_Left", true);
                    break;

                case InputDir.Right:
                    ActionCtrl.SetBool("Dir_Right", true);
                    break;

                default:
                    ActionCtrl.SetBool("Dir_Right", false);
                    ActionCtrl.SetBool("Dir_Left", false);
                    break;
                }
                switch (handInput.GetVertEnum())
                {
                case InputDir.Up:
                    ActionCtrl.SetBool("Dir_Up", true);
                    break;

                case InputDir.Down:
                    ActionCtrl.SetBool("Dir_Down", true);
                    break;

                default:
                    ActionCtrl.SetBool("Dir_Up", false);
                    ActionCtrl.SetBool("Dir_Down", false);
                    break;
                }
            }
            switch (handInput.gesture)
            {
            case HandGesture.Click:
                ActionCtrl.SetBool("Hand_Click", true);
                break;

            case HandGesture.Drag:
                ActionCtrl.SetBool("Hand_Drag", true);
                break;

            case HandGesture.Slip:
                ActionCtrl.SetBool("Hand_Slip", true);
                break;

            case HandGesture.Holding:
                ActionCtrl.SetBool("Hand_Holding", true);
                break;

            case HandGesture.Realease:
                ActionCtrl.SetBool("Hand_Release", true);
                break;

            default:
                ActionCtrl.SetBool("Hand_Drag", false);
                ActionCtrl.SetBool("Hand_Click", false);
                ActionCtrl.SetBool("Hand_Slip", false);
                ActionCtrl.SetBool("Hand_Holding", false);
                break;
            }
        }
Example #21
0
 public void CreateLapEndSnapshot(DriverInfo driverInfo, WeatherInfo weather, InputInfo inputInfo, SimulatorSourceInfo simulatorSourceInfo)
 {
     LapEndSnapshot = new TelemetrySnapshot(driverInfo, weather, inputInfo, simulatorSourceInfo);
 }
Example #22
0
		public static extern bool vbmp3_open(string pszName, ref InputInfo pInfo);
Example #23
0
		private void listBoxGarbageFiles_DoubleClick(object sender, System.EventArgs e)
		{
			vbmp3_stop();
			
			if (listBoxGarbageFiles.SelectedItem != null)
			{
				string itemname = listBoxGarbageFiles.SelectedItem.ToString().ToLower();

				if (itemname.EndsWith(".bmp") ||
					itemname.EndsWith(".jpg") ||
					itemname.EndsWith(".jpeg") ||
					itemname.EndsWith(".png") ||
					itemname.EndsWith(".gif")
					)
				{
					this.Text = titletext + " Loading...";
					try
					{
						labelBGA.Image = Image.FromFile(currentpath + @"\" + listBoxGarbageFiles.SelectedItem.ToString());
					}
					catch
					{
						MessageBox.Show("画像ファイル読み込み中にエラーが発生しました。","エラー");
					}
					this.Text = titletext;
				}

				if (itemname.EndsWith(".wav"))
				{
					this.Text = titletext + " Loading...";
					try
					{
						/*// ファイルからバイト配列に読み込み
						FileStream stream;
						BinaryReader reader;
						stream = new FileStream(currentpath + @"\" + listBoxGarbageFiles.SelectedItem.ToString(), FileMode.Open, FileAccess.Read );
						reader = new BinaryReader( stream );
						buffer = reader.ReadBytes( (int)stream.Length );
						reader.Close();
						stream.Close();
						*/

						/*// バッファから再生
						PlaySound( buffer, 0, SND_MEMORY | SND_ASYNC );
						*/

						// ファイルから再生
						PlaySound( currentpath + @"\" + listBoxGarbageFiles.SelectedItem.ToString(), 0, SND_ASYNC );

					}
					catch
					{
						MessageBox.Show("音声ファイル読み込み中にエラーが発生しました。","エラー");
					}
					this.Text = titletext;
				}

				if (itemname.EndsWith(".mp3"))
				{
					this.Text = titletext + " Loading...";
					try
					{
						InputInfo data = new InputInfo();
						if(vbmp3_open(currentpath + @"\" + listBoxGarbageFiles.SelectedItem.ToString(), ref data))
						{
							vbmp3_play();
						}
					}
					catch
					{
						MessageBox.Show("音声ファイル読み込み中にエラーが発生しました。","エラー");
					}
					this.Text = titletext;
				}
			}
		}
Example #24
0
    /// <summary>
    /// Adds the supplied input info to given frame
    /// </summary>
    /// <param name='atFrame'>
    /// At frame.
    /// </param>
    /// <param name='inputInfo'>
    /// Input info.
    /// </param>
    public void AddInput( int atFrame, InputInfo inputInfo )
    {
        CheckFrame( atFrame );

        for ( int i = 0; i < frames[atFrame].inputs.Count; i++ )
        {
            // no duplicate properties
            if ( frames[atFrame].inputs[i].inputName == inputInfo.inputName )
            {
                frames[atFrame].inputs[i] = new InputInfo( inputInfo );
                return;
            }
        }

        frames[atFrame].inputs.Add( new InputInfo( inputInfo ) );
    }
Example #25
0
 private void ProcessRelease(InputInfo inputInfo)
 {
     SendMessage("OnPressUp", inputInfo.pressedGameObject, inputInfo);
 }
Example #26
0
        public bool Equals( InputInfo other )
        {
            if ( other == null )
                return false;

            if ( inputName != other.inputName || inputType != other.inputType || mouseButtonNum != other.mouseButtonNum )
                return false;

            if ( inputType == InputType.Axis )
                return axisValue == other.axisValue;
            else
                return buttonState == other.buttonState;
        }
    public override void OnInspectorGUI()
    {
        myTarget = (InputController)target;

        deleteInfo   = null;
        moveDownInfo = null;
        moveUpInfo   = null;

        showKeyBinding = GUILayout.Toggle(showKeyBinding, "Show Key Bindings");

        allScrollValue = GUILayout.BeginScrollView(allScrollValue, GUILayout.MinHeight(800));

        GUILayout.Label("Input Infos:");

        inputInfoScrollValue = EditorGUILayout.BeginScrollView(inputInfoScrollValue);

        for (int i = 0; i < myTarget.InputInfos.Count; i++)
        {
            InputInfo inputInfo = myTarget.InputInfos[i];

            GUILayout.BeginHorizontal();
            GUILayout.Label("Input Type:");
            if (i > 0 && GUILayout.Button("/\\", GUILayout.Width(30)))
            {
                moveUpInfo = inputInfo;
            }
            if (i < myTarget.InputInfos.Count - 1 && GUILayout.Button("\\/", GUILayout.Width(30)))
            {
                moveDownInfo = inputInfo;
            }
            if (GUILayout.Button("Remove Info"))
            {
                deleteInfo = inputInfo;
            }
            GUILayout.EndHorizontal();

            inputInfo.Action = EditorGUILayout.TextField(inputInfo.Action);

            if (showKeyBinding)
            {
                GUILayout.BeginHorizontal();
                inputInfo.ActionType = (ActionType)EditorGUILayout.EnumPopup(inputInfo.ActionType);
                inputInfo.InputType  = (InputType)EditorGUILayout.EnumPopup(inputInfo.InputType);
                GUILayout.EndHorizontal();

                if (inputInfo.InputType == InputType.KEYCODE)
                {
                    inputInfo.key = (KeyCode)EditorGUILayout.EnumPopup(inputInfo.key);
                }
                else
                {
                    if (inputInfo.InputType == InputType.MOUSEBUTTON)
                    {
                        inputInfo.mouseButtonID = EditorGUILayout.IntField(inputInfo.mouseButtonID);
                    }
                    else
                    {
                        inputInfo.inputString = EditorGUILayout.TextField(inputInfo.inputString);
                    }
                }
            }



            GUILayout.Space(5);
        }

        EditorGUILayout.EndScrollView();

        if (deleteInfo != null)
        {
            myTarget.InputInfos.Remove(deleteInfo);
            deleteInfo = null;
        }
        if (moveUpInfo != null)
        {
            moveUpInfo = null;
            int       index = myTarget.InputInfos.IndexOf(moveUpInfo);
            InputInfo tmp   = myTarget.InputInfos[index - 1];

            myTarget.InputInfos[index]     = tmp;
            myTarget.InputInfos[index - 1] = moveUpInfo;
        }
        if (moveDownInfo != null)
        {
            moveDownInfo = null;
            int       index = myTarget.InputInfos.IndexOf(moveDownInfo);
            InputInfo tmp   = myTarget.InputInfos[index + 1];

            myTarget.InputInfos[index]     = tmp;
            myTarget.InputInfos[index + 1] = moveDownInfo;
        }


        if (GUILayout.Button("Add new Info"))
        {
            myTarget.InputInfos.Add(new InputInfo());
        }

        GUILayout.Label("UnityButtons:");
        unityButtonsScrollValue = EditorGUILayout.BeginScrollView(unityButtonsScrollValue, GUILayout.MaxHeight(400), GUILayout.MinHeight(50));

        string deleteButton = string.Empty;

        for (int i = 0; i < myTarget.unityButtonInputs.Count; i++)
        {
            myTarget.unityButtonInputs[i] = EditorGUILayout.TextField(myTarget.unityButtonInputs[i]);
            if (GUILayout.Button("Remove Button"))
            {
                deleteButton = myTarget.unityButtonInputs[i];
                break;
            }
        }
        if (!string.IsNullOrEmpty(deleteButton))
        {
            myTarget.unityButtonInputs.Remove(deleteButton);
        }
        EditorGUILayout.EndScrollView();
        if (GUILayout.Button("Add new UnityButton"))
        {
            myTarget.unityButtonInputs.Add("NewButton");
        }


        GUILayout.Label("Unity Axis:");
        unityAxisScrollValue = EditorGUILayout.BeginScrollView(unityAxisScrollValue, GUILayout.MaxHeight(400), GUILayout.MinHeight(50));

        for (int i = 0; i < myTarget.unityAxisInputs.Count; i++)
        {
            myTarget.unityAxisInputs[i] = EditorGUILayout.TextField(myTarget.unityAxisInputs[i]);
        }

        EditorGUILayout.EndScrollView();
        if (GUILayout.Button("Add new UnityAxis"))
        {
            myTarget.unityAxisInputs.Add("NewAxis");
        }

        GUILayout.EndScrollView();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(myTarget);
        }
    }
Example #28
0
    private void FingerUp(UInt16 x, UInt16 y)
    {
        if (!inputEnable ||
            touchUp.Count >= kMaxPointNumber)
            return;

        InputInfo info = new InputInfo();
        info.x = x;
        info.y = y;
        info.time = Time.realtimeSinceStartup;
        info.state = 0;
        touchUp.Enqueue(info);
        //		Debug.Log("FingerUp x:" + x + ", y:" + y);
    }
Example #29
0
 public TimedTelemetrySnapshot(TimeSpan lapTime, DriverInfo playerInfo, WeatherInfo weatherInfo, InputInfo inputInfo, SimulatorSourceInfo simulatorSourceInfo) : base(playerInfo, weatherInfo, inputInfo, simulatorSourceInfo)
 {
     LapTime = lapTime;
 }
Example #30
0
    private void MouseButtonUp()
    {
        if (!inputEnable ||
            mouseUp.Count >= kMaxPointNumber)
            return;

        float x = GameData.GetInstance().serialMouseX;
        float y = GameData.GetInstance().serialMouseY;
        InputInfo info = new InputInfo();
        info.x = x;
        info.y = y;
        info.time = Time.realtimeSinceStartup;
        info.state = 0;
        mouseUp.Enqueue(info);
    }
        /// <inheritdoc/>
        public bool Automate_SetInput(IStorage input, MassProductionMachineDefinition mpm, IMachine originalMachine, SObject originalMachineObject)
        {
            if (mpm != null)
            {
                try
                {
                    ITrackedStack crop          = null;
                    InputInfo     cropInfo      = null;
                    int           inputQuantity = 0;

                    foreach (ITrackedStack item in input.GetItems())
                    {
                        if (IsValidCrop(item))
                        {
                            InputInfo inputInfo = new InputInfo()
                            {
                                ID           = item.Sample.ParentSheetIndex,
                                Name         = item.Sample.Name,
                                Quality      = 0,
                                IsFuel       = false,
                                BaseQuantity = 1
                            };

                            if (item.Sample is SObject obj)
                            {
                                inputInfo.Quality = obj.Quality;
                            }

                            inputQuantity = mpm.Settings.CalculateInputRequired(inputInfo);

                            if (item.Count >= inputQuantity)
                            {
                                crop     = item;
                                cropInfo = inputInfo;
                                break;
                            }
                        }
                    }

                    if (crop != null)
                    {
                        crop.Reduce(inputQuantity);
                        int seedID = SEED_LOOKUP[crop.Sample.ParentSheetIndex];

                        Random random = new Random((int)Game1.stats.DaysPlayed +
                                                   (int)Game1.uniqueIDForThisGame / 2 + (int)originalMachineObject.TileLocation.X + (int)originalMachineObject.TileLocation.Y * 77 + Game1.timeOfDay);
                        int outputID       = seedID;
                        int outputQuantity = mpm.Settings.CalculateOutputProduced(random.Next(1, 4), cropInfo);

                        if (random.NextDouble() < 0.005)
                        {
                            outputID       = 499;
                            outputQuantity = mpm.Settings.CalculateOutputProduced(1, cropInfo);
                        }
                        else if (random.NextDouble() < 0.02)
                        {
                            outputID       = 770;
                            outputQuantity = mpm.Settings.CalculateOutputProduced(random.Next(1, 5), cropInfo);
                        }

                        originalMachineObject.heldObject.Value  = new SObject(outputID, outputQuantity);
                        originalMachineObject.MinutesUntilReady = mpm.Settings.CalculateTimeRequired(20);

                        return(true);
                    }
                }
                catch (Exception e)
                {
                    ModEntry.Instance.Monitor.Log($"{e}", StardewModdingAPI.LogLevel.Error);
                }
            }
            else
            {
                return(originalMachine.SetInput(input));
            }

            return(false);
        }
Example #32
0
 void GameIntroduce()
 {
     InputInfo.Invoke(this, new GameEventArgs(_gameIntroduce, ConsoleColor.DarkGreen));
     InputInfo.Invoke(this, new GameEventArgs(_gameInstructions, ConsoleColor.DarkGreen));
 }
Example #33
0
        private void UpdateConflictWarning()
        {
            bool needWarning = false;

            bool[] portConflicts = new bool[6];
            Dictionary <uint, List <int> > mappedKeys   = new Dictionary <uint, List <int> >();
            Action <int, uint>             countMapping = (int port, uint keyCode) => {
                if (keyCode > 0)
                {
                    if (mappedKeys.ContainsKey(keyCode))
                    {
                        needWarning = true;
                        mappedKeys[keyCode].Add(port);
                        foreach (int conflictingPorts in mappedKeys[keyCode])
                        {
                            portConflicts[conflictingPorts] = true;
                        }
                    }
                    else
                    {
                        mappedKeys.Add(keyCode, new List <int>()
                        {
                            port
                        });
                    }
                }
            };

            InputInfo inputInfo = (InputInfo)Entity;

            for (int i = 0; i < 4; i++)
            {
                ControllerInfo controllerInfo = inputInfo.Controllers[i];
                if (i < 2 || this.FourScoreAttached && ((i == 2 && btnSetupP3.Enabled) || (i == 3 && btnSetupP4.Enabled)))
                {
                    foreach (KeyMappings mappings in controllerInfo.Keys)
                    {
                        switch (controllerInfo.ControllerType)
                        {
                        case InteropEmu.ControllerType.StandardController:
                        case InteropEmu.ControllerType.SnesController:
                            countMapping(i, mappings.A);
                            countMapping(i, mappings.B);
                            countMapping(i, mappings.Select);
                            countMapping(i, mappings.Start);
                            countMapping(i, mappings.TurboA);
                            countMapping(i, mappings.TurboB);
                            countMapping(i, mappings.TurboSelect);
                            countMapping(i, mappings.TurboStart);
                            countMapping(i, mappings.Up);
                            countMapping(i, mappings.Down);
                            countMapping(i, mappings.Left);
                            countMapping(i, mappings.Right);
                            if (i == 1 && inputInfo.ConsoleType == ConsoleType.Famicom && controllerInfo.ControllerType == InteropEmu.ControllerType.StandardController)
                            {
                                countMapping(i, mappings.Microphone);
                            }
                            if (controllerInfo.ControllerType == InteropEmu.ControllerType.SnesController)
                            {
                                countMapping(i, mappings.LButton);
                                countMapping(i, mappings.RButton);
                            }
                            break;

                        case InteropEmu.ControllerType.PowerPad:
                            foreach (UInt32 button in mappings.PowerPadButtons.Values)
                            {
                                countMapping(i, button);
                            }
                            break;

                        case InteropEmu.ControllerType.VbController:
                            foreach (UInt32 button in mappings.VirtualBoyButtons.Values)
                            {
                                countMapping(i, button);
                            }
                            break;
                        }
                    }
                }
            }

            if (inputInfo.ConsoleType == ConsoleType.Famicom)
            {
                foreach (KeyMappings mappings in inputInfo.Controllers[0].Keys)
                {
                    switch (inputInfo.ExpansionPortDevice)
                    {
                    case InteropEmu.ExpansionPortDevice.ExcitingBoxing:
                        foreach (UInt32 button in mappings.ExcitingBoxingButtons.Values)
                        {
                            countMapping(4, button);
                        }
                        break;

                    case InteropEmu.ExpansionPortDevice.FamilyTrainerMat:
                        foreach (UInt32 button in mappings.PowerPadButtons.Values)
                        {
                            countMapping(4, button);
                        }
                        break;

                    case InteropEmu.ExpansionPortDevice.JissenMahjong:
                        foreach (UInt32 button in mappings.JissenMahjongButtons.Values)
                        {
                            countMapping(4, button);
                        }
                        break;

                    case InteropEmu.ExpansionPortDevice.Pachinko:
                        foreach (UInt32 button in mappings.PachinkoButtons.Values)
                        {
                            countMapping(4, button);
                        }
                        break;

                    case InteropEmu.ExpansionPortDevice.PartyTap:
                        foreach (UInt32 button in mappings.PartyTapButtons.Values)
                        {
                            countMapping(4, button);
                        }
                        break;
                    }
                }
            }

            if (_hasCartridgeInput && btnSetupCartridge.Enabled)
            {
                //Bandai microphone
                foreach (KeyMappings mappings in inputInfo.Controllers[0].Keys)
                {
                    foreach (UInt32 button in mappings.BandaiMicrophoneButtons.Values)
                    {
                        countMapping(5, button);
                    }
                }
            }

            if (pnlConflictWarning.Visible != needWarning)
            {
                pnlConflictWarning.Visible = needWarning;
                this.Height = (int)(((needWarning ? 360 : 310) + (_hasCartridgeInput ? 30 : 0)) * _yFactor);
            }
            if (portConflicts[0] == (btnSetupP1.Image == null))
            {
                btnSetupP1.Image = portConflicts[0] ? Properties.Resources.Warning : null;
            }
            if (portConflicts[1] == (btnSetupP2.Image == null))
            {
                btnSetupP2.Image = portConflicts[1] ? Properties.Resources.Warning : null;
            }
            if (portConflicts[2] == (btnSetupP3.Image == null))
            {
                btnSetupP3.Image = portConflicts[2] ? Properties.Resources.Warning : null;
            }
            if (portConflicts[3] == (btnSetupP4.Image == null))
            {
                btnSetupP4.Image = portConflicts[3] ? Properties.Resources.Warning : null;
            }
            if (portConflicts[4] == (btnSetupExp.Image == null))
            {
                btnSetupExp.Image = portConflicts[4] ? Properties.Resources.Warning : null;
            }
            if (portConflicts[5] == (btnSetupCartridge.Image == null))
            {
                btnSetupCartridge.Image = portConflicts[5] ? Properties.Resources.Warning : null;
            }
        }
Example #34
0
        void GetInput()
        {
            InputInfo t;
            int       ind = 0;
            Camera    cam = m_InputCamera ? m_InputCamera : Camera.main;

            if (cam)
            {
                // Mouse event
                t = m_Input[ind];

                if (m_UseMouseEvents)
                {
                    if (Input.GetMouseButton(m_MouseButton))
                    {
                        t.worldPosition = cam.ScreenToWorldPoint(Input.mousePosition);
                        t.worldDistance = cam.GetPixelWidth(t.worldPosition) * m_MouseDistance;

                        if (t._endPhase)
                        {
                            // Starting a click
                            t._beginPhase = true;
                            t._endPhase   = false;
                        }
                        else if (t._beginPhase)
                        {
                            // Holding down a click
                            t._beginPhase = false;
                        }
                    }
                    else
                    {
                        // Released a click
                        t._endPhase   = true;
                        t._beginPhase = false;
                    }
                }
                else
                {
                    t._beginPhase = false;
                    t._endPhase   = false;
                }

                m_Input[ind] = t;

                // Touch events
                for (int i = 1; i < touchCount + 1; i++)
                {
                    m_ToRemove.Add(i);
                }

                if (m_UseTouchEvents)
                {
                    // Add new touches
                    int tc = Input.touchCount;
                    for (int i = 0; i < tc; ++i)
                    {
                        var touch = Input.GetTouch(i);

                        ind = touch.fingerId + 1;
                        t   = m_Input[ind];

                        if (t._endPhase)
                        {
                            // Starting a new touch
                            t._beginPhase = true;
                            t._endPhase   = false;
                        }
                        else if (t._beginPhase)
                        {
                            // Holding down a touch
                            t._beginPhase = false;
                        }

                        t._touch        = touch;
                        t.worldPosition = cam.ScreenToWorldPoint(touch.position);
                        t.worldDistance = cam.GetPixelWidth(t.worldPosition) * m_TouchDistance;
                        m_Input[ind]    = t;

                        m_ToRemove.Remove(ind);
                    }
                }

                // Remove old touches
                int l = m_ToRemove.Count;
                for (int i = 0; i < l; i++)
                {
                    ind = m_ToRemove[i];
                    InputInfo rem = m_Input[ind];

                    rem._endPhase   = true;
                    rem._beginPhase = false;

                    m_Input[ind] = rem;
                }

                m_ToRemove.Clear();
            }

            // Custom events
            for (int i = m_Input.Count - 1; i >= touchCount + 1; --i)
            {
                m_Input.RemoveAt(i);
            }

            for (int i = 0; i < m_OnCustomInputList.Count; i++)
            {
                var del = m_OnCustomInputList[i];
                m_Input.Add(del(this));
            }
        }
        public override bool Equals(object obj)
        {
            InputInfo other = obj as InputInfo;

            return(Equals(other));
        }
Example #36
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var       isChanged = false;
            InputInfo inputInfo;

            if (Body.IsQueryExists("InputID"))
            {
                try
                {
                    var inputId = Body.GetQueryInt("InputID");
                    inputInfo = DataProvider.InputDao.GetInputInfo(inputId);
                    if (inputInfo != null)
                    {
                        if (inputInfo.InputName != InputName.Text)
                        {
                            inputInfo.InputName = InputName.Text;
                        }
                        inputInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue);
                        inputInfo.IsReply   = TranslateUtils.ToBool(IsReply.SelectedValue);

                        inputInfo.Additional.MessageSuccess = MessageSuccess.Text;
                        inputInfo.Additional.MessageFailure = MessageFailure.Text;

                        inputInfo.Additional.IsAnomynous     = TranslateUtils.ToBool(IsAnomynous.SelectedValue);
                        inputInfo.Additional.IsSuccessHide   = TranslateUtils.ToBool(IsSuccessHide.SelectedValue);
                        inputInfo.Additional.IsSuccessReload = TranslateUtils.ToBool(IsSuccessReload.SelectedValue);
                        inputInfo.Additional.IsCtrlEnter     = TranslateUtils.ToBool(IsCtrlEnter.SelectedValue);
                    }
                    DataProvider.InputDao.Update(inputInfo);

                    Body.AddSiteLog(PublishmentSystemId, "修改提交表单", $"提交表单:{inputInfo.InputName}");

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "提交表单修改失败!");
                }
            }
            else
            {
                var inputNameArrayList = DataProvider.InputDao.GetInputNameArrayList(PublishmentSystemId);
                if (inputNameArrayList.IndexOf(InputName.Text) != -1)
                {
                    FailMessage("提交表单添加失败,提交表单名称已存在!");
                }
                else
                {
                    try
                    {
                        inputInfo = new InputInfo
                        {
                            InputName           = InputName.Text,
                            PublishmentSystemId = PublishmentSystemId,
                            IsChecked           = TranslateUtils.ToBool(IsChecked.SelectedValue),
                            IsReply             = TranslateUtils.ToBool(IsReply.SelectedValue)
                        };

                        inputInfo.Additional.MessageSuccess = MessageSuccess.Text;
                        inputInfo.Additional.MessageFailure = MessageFailure.Text;

                        inputInfo.Additional.IsAnomynous     = TranslateUtils.ToBool(IsAnomynous.SelectedValue);
                        inputInfo.Additional.IsSuccessHide   = TranslateUtils.ToBool(IsSuccessHide.SelectedValue);
                        inputInfo.Additional.IsSuccessReload = TranslateUtils.ToBool(IsSuccessReload.SelectedValue);
                        inputInfo.Additional.IsCtrlEnter     = TranslateUtils.ToBool(IsCtrlEnter.SelectedValue);

                        DataProvider.InputDao.Insert(inputInfo);

                        Body.AddSiteLog(PublishmentSystemId, "添加提交表单", $"提交表单:{inputInfo.InputName}");

                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "提交表单添加失败!");
                    }
                }
            }

            if (isChanged)
            {
                if (_isPreview)
                {
                    PageUtils.CloseModalPage(Page);
                }
                else
                {
                    PageUtils.CloseModalPageAndRedirect(Page, PageInput.GetRedirectUrl(PublishmentSystemId));
                }
            }
        }
Example #37
0
 private static void SetInputInfo(DependencyObject element, InputInfo value) => element.SetValue(InputInfoProperty, value);
Example #38
0
 // Start is called before the first frame update
 void Start()
 {
     inputInfo = new InputInfo();
 }
Example #39
0
    void LateUpdate()
    {
        if ( _mode == InputVCRMode.Playback )
        {
            // update last frame and this frame
            // this way, all changes are transmitted, even if a button press lasts less than a frame (like in Input)
            lastFrameInputs = thisFrameInputs;

            int lastFrame = currentFrame;
            currentFrame = currentRecording.GetClosestFrame ( playbackTime );

            if ( currentFrame > currentRecording.totalFrames )
            {
                // end of recording
                if ( finishedPlayback != null )
                    finishedPlayback( );
                Stop ();
            }
            else
            {
                // go through all changes in recorded input since last frame
                var changedInputs = new Dictionary<string, InputInfo>();
                for( int frame = lastFrame + 1; frame <= currentFrame; frame++ )
                {
                    foreach( InputInfo input in currentRecording.GetInputs ( frame ) )
                    {
                        // thisFrameInputs only updated once per game frame, so all changes, no matter how brief, will be marked
                        // if button has changed
                        if ( !thisFrameInputs.ContainsKey ( input.inputName ) || !thisFrameInputs[input.inputName].Equals( input ) )
                        {
                            if ( changedInputs.ContainsKey ( input.inputName ) )
                                changedInputs[input.inputName] = input;
                            else
                                changedInputs.Add( input.inputName, input );
                        }
                    }

                    if ( snapToSyncedLocation )	// custom code more effective, but this is enough sometimes
                    {
                        string posString = currentRecording.GetProperty ( frame, "position" );
                        if ( !string.IsNullOrEmpty ( posString ) )
                            transform.position = ParseVector3 ( posString );

                        string rotString = currentRecording.GetProperty ( frame, "rotation" );
                        if ( !string.IsNullOrEmpty( rotString ) )
                            transform.eulerAngles = ParseVector3 ( rotString );
                    }
                }

                // update input to be used tihs frame
                foreach( KeyValuePair<string, InputInfo> changedInput in changedInputs )
                {
                    if ( thisFrameInputs.ContainsKey ( changedInput.Key ) )
                        thisFrameInputs[changedInput.Key] = changedInput.Value;
                    else
                        thisFrameInputs.Add ( changedInput.Key, changedInput.Value );
                }

                playbackTime += Time.deltaTime;
            }
        }
        else if ( _mode == InputVCRMode.Record )
        {
            realRecordingTime += Time.deltaTime;
            // record current input to frames, until recording catches up with realtime
            while ( currentTime < realRecordingTime )
            {
                // mouse position & buttons if required
                if ( recordMouseEvents )
                {
                    currentRecording.AddProperty( currentFrame, new FrameProperty( "mousePos", Input.mousePosition.x.ToString() + "," + Input.mousePosition.y ) );

                    for( int i = 0; i < 3; i++ )
                    {
                        InputInfo mouseInput = new InputInfo();
                        mouseInput.inputName = "mousebutton" + i;
                        mouseInput.isAxis = false;
                        mouseInput.mouseButtonNum = i;
                        currentRecording.AddInput ( currentFrame, mouseInput );
                    }
                }

                // and buttons
                foreach( InputInfo input in inputsToRecord )
                {
                    if ( input.isAxis )
                        input.axisValue = Input.GetAxis ( input.inputName );
                    else if ( input.mouseButtonNum >= 0 )	// mouse buttons recorded above
                        input.buttonState = Input.GetButton ( input.inputName );
                    currentRecording.AddInput ( currentFrame, input );
                }

                // synced location
                if ( syncRecordLocations && Time.time > nextPosSyncTime )
                {
                    SyncPosition ();	// add position to properties
                    nextPosSyncTime = Time.time + 1f / autoSyncLocationRate;
                }

                // and any other properties
                foreach( FrameProperty prop in nextPropertiesToRecord )
                    currentRecording.AddProperty ( currentFrame, prop );
                nextPropertiesToRecord.Clear ();

                currentFrame++;
            }
        }
    }
Example #40
0
        public void ImportInput(bool overwrite)
        {
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                return;
            }
            var filePaths = DirectoryUtils.GetFilePaths(_directoryPath);

            foreach (var filePath in filePaths)
            {
                var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                var inputInfo = new InputInfo
                {
                    InputName           = AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputName"),
                    PublishmentSystemId = _publishmentSystemId,
                    AddDate             = DateTime.Now,
                    IsChecked           =
                        TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsChecked")),
                    IsReply     = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsReply")),
                    Taxis       = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "Taxis")),
                    SettingsXml =
                        AtomUtility.Decrypt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "SettingsXML"))
                };

                var srcInputInfo = DataProvider.InputDao.GetInputInfo(inputInfo.InputName, _publishmentSystemId);
                if (srcInputInfo != null)
                {
                    if (overwrite)
                    {
                        DataProvider.InputDao.Delete(srcInputInfo.InputId);
                    }
                    else
                    {
                        inputInfo.InputName = DataProvider.InputDao.GetImportInputName(inputInfo.InputName, _publishmentSystemId);
                    }
                }

                var inputId = DataProvider.InputDao.Insert(inputInfo);

                var styleDirectoryPath = PathUtils.Combine(_directoryPath, AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputID"));
                TableStyleIe.SingleImportTableStyle(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, styleDirectoryPath, inputId);

                foreach (AtomEntry entry in feed.Entries)
                {
                    var contentInfo = new InputContentInfo
                    {
                        InputId   = inputId,
                        IsChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.IsChecked)),
                        UserName  = AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.UserName),
                        AddDate   = DateTime.Now,
                        Reply     = AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.Reply)
                    };
                    var attributes = AtomUtility.GetDcElementNameValueCollection(entry.AdditionalElements);
                    foreach (string entryName in attributes.Keys)
                    {
                        if (!InputContentAttribute.AllAttributes.Contains(entryName.ToLower()))
                        {
                            contentInfo.SetExtendedAttribute(entryName, attributes[entryName]);
                        }
                    }
                    DataProvider.InputContentDao.Insert(contentInfo);
                }
            }
        }
Example #41
0
 // starts user input polling
 public void Start()
 {
     lock (timerLock)
     {
         initialInfo.Update();
         actualInfo = (InputInfo)initialInfo.Clone();
         timer.Start();
     }
 }
        /// <summary>
        /// Adapted from https://github.com/Digus/StardewValleyMods/blob/master/PFMAutomate/Automate/CustomProducerMachine.cs
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public bool SetInput(IStorage input)
        {
            if (IsMassProducer)
            {
                MassProductionMachineDefinition mpm = ModEntry.GetMPMMachine(Machine.name, Machine.GetMassProducerKey());

                foreach (ITrackedStack trackedStack in input.GetItems())
                {
                    if (trackedStack.Sample is SObject objectInput && !objectInput.bigCraftable.Value &&
                        ProducerController.GetProducerItem(Machine.Name, objectInput) is ProducerRule producerRule &&
                        !PFMCompatability.IsInputExcluded(producerRule, mpm, objectInput))
                    {
                        ProducerConfig producerConfig = mpm.GetBaseProducerConfig();

                        if (producerConfig == null || (producerConfig.CheckLocationCondition(Location) && producerConfig.CheckSeasonCondition()))
                        {
                            List <InputInfo> inputsRequired = InputInfo.ConvertPFMInputs(producerRule, objectInput);

                            if (inputsRequired.Count > 0 &&
                                input.TryGetIngredient(objectInput.ParentSheetIndex, mpm.Settings.CalculateInputRequired(inputsRequired.First()), out IConsumable inputConsumable))
                            {
                                objectInput = inputConsumable.Sample as SObject;
                                List <IConsumable> requiredFuels = GetRequiredFuels(inputsRequired, mpm.Settings, input);

                                if (requiredFuels != null)
                                {
                                    try
                                    {
                                        Dictionary <int, int> fuelQuantities = new Dictionary <int, int>();

                                        foreach (InputInfo inputInfo in inputsRequired)
                                        {
                                            if (inputInfo.IsFuel)
                                            {
                                                fuelQuantities.Add(inputInfo.ID, mpm.Settings.CalculateInputRequired(inputInfo));
                                            }
                                        }

                                        Func <int, int, bool> fuelSearch   = (i, q) => input.TryGetIngredient(i, fuelQuantities[i], out IConsumable fuel);
                                        OutputConfig          outputConfig = PFMCompatability.ProduceOutput(producerRule, mpm.Settings, Machine, fuelSearch, null, Location, producerConfig,
                                                                                                            objectInput, inputQuantity: mpm.Settings.CalculateInputRequired(inputsRequired.First()), noSoundAndAnimation: true,
                                                                                                            inputInfo: inputsRequired);

                                        if (outputConfig != null)
                                        {
                                            inputConsumable.Take();
                                            requiredFuels.ForEach(f => f.Reduce());
                                            List <IConsumable> outputRequiredFuels = GetRequiredFuels(InputInfo.ConvertPFMInputs(outputConfig), mpm.Settings, input);
                                            outputRequiredFuels.ForEach(f => f.Reduce());
                                            return(true);
                                        }
                                    }
                                    catch (RestrictionException) { /* No action needed */ }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (ITrackedStack trackedStack in input.GetItems())
                {
                    if (trackedStack.Sample is SObject objectInput && !objectInput.bigCraftable.Value &&
                        ProducerController.GetProducerItem(Machine.Name, objectInput) is ProducerRule producerRule &&
                        !ProducerRuleController.IsInputExcluded(producerRule, objectInput))
                    {
                        ProducerConfig producerConfig = ProducerController.GetProducerConfig(Machine.name);

                        if (producerConfig == null || (producerConfig.CheckLocationCondition(Location) && producerConfig.CheckSeasonCondition()))
                        {
                            if (input.TryGetIngredient(objectInput.ParentSheetIndex, producerRule.InputStack, out IConsumable inputConsumable))
                            {
                                objectInput = inputConsumable.Sample as SObject;
                                List <IConsumable> requiredFuels = GetRequiredFuels(InputInfo.ConvertPFMInputs(producerRule, objectInput), null, input);

                                if (requiredFuels != null)
                                {
                                    try
                                    {
                                        Func <int, int, bool> fuelSearch   = (i, q) => input.TryGetIngredient(i, q, out IConsumable fuel);
                                        OutputConfig          outputConfig = ProducerRuleController.ProduceOutput(producerRule, Machine, fuelSearch, null, Location, producerConfig,
                                                                                                                  objectInput, noSoundAndAnimation: true);

                                        if (outputConfig != null)
                                        {
                                            inputConsumable.Take();
                                            requiredFuels.ForEach(f => f.Reduce());
                                            List <IConsumable> outputRequiredFuels = GetRequiredFuels(InputInfo.ConvertPFMInputs(outputConfig), null, input);
                                            outputRequiredFuels.ForEach(f => f.Reduce());
                                            return(true);
                                        }
                                    }
                                    catch (RestrictionException) { /* No action needed */ }
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #43
0
 public void MsgClick(InputInfo info)
 {
     Debug.Log("Start Game.");
     GameManager.instance.ChangeState(new GameState(GameManager.instance));
 }
Example #44
0
 void OnPressDown(InputInfo input)
 {
     cactus.Dance();
 }
Example #45
0
 private void UpdateDragState()
 {
     Vector2 tapDown;
     if( TapDown( out tapDown ) == false ) {
         touchState = TouchState.TapUp;
         SendTapUpMessage( MakeHitInputEvent() );
         lastTouch = currTouch;
     } else if( (tapDown - currTouch.pos).magnitude > deadZone ) {
         currTouch.pos = tapDown;
         SendDragMessage( MakeInputEvent() );  // No raycast for drag
         lastTouch = currTouch;
     }
 }
Example #46
0
 private void UpdateDragState()
 {
     Vector3 tapDown = TapDown();
     if( tapDown == Vector3.zero ) {
         touchState = TouchState.TapUp;
         SendTapUpMessage( MakeHitInputEvent() );
         lastTouch = currTouch;
         return;
     }
     else if( (tapDown - currTouch.pos).magnitude > deadZone ) {
             currTouch.pos = tapDown;
             SendDragMessage( MakeInputEvent() );  // No raycast for drag
             lastTouch = currTouch;
         }
 }