示例#1
0
        private void CacheUserList()
        {
            MySqlCommand command = conn.CreateCommand();

            if (string.IsNullOrEmpty(db_where_clause))
            {
                command.CommandText = String.Format("SELECT DISTINCT(userID) FROM {0};", db_table);
            }
            else
            {
                command.CommandText = String.Format("SELECT DISTINCT(userID) FROM {0} WHERE {1};", db_table, db_where_clause);
            }

            try {
                conn.Open();
            }
            catch (Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            Debug.LogFormat("<color=purple>MySQL Query:</color> {0}", command.CommandText);
            MySqlDataReader reader = command.ExecuteReader();

            cached_users = new List <string>();
            while (reader.Read())
            {
                cached_users.Add(reader.GetString(0));
            }

            conn.Close();

            current_user_dex = 0;
        }
        public override IEnumerator Initialize()
        {
            ConnectionString = System.String.Format("Server={0};Port={1};Database={2};Uid={3};password={4}",
                                                    server,
                                                    portNum,
                                                    database,
                                                    userID,
                                                    password);
            conn = new MySqlConnection(ConnectionString);

            MySqlCommand command = conn.CreateCommand();

            command.CommandText    = CommandString;
            command.CommandTimeout = 999999;

            try {
                conn.Open();
            }
            catch (System.Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }

            reader = command.ExecuteReader();
            loaded = true;
            RequestNextAction();
            yield break;
        }
示例#3
0
 void OnGUI()
 {
     if (!string.IsNullOrEmpty(errorMessage))
     {
         if (ReplayGUI.ErrorMessage(errorMessage))
         {
             errorMessage = string.Empty;
         }
     }
 }
示例#4
0
 void Awake()
 {
     if (mainGUI == null)
     {
         mainGUI = this;
     }
     else
     {
         Debug.LogError("More than 1 ReplayGUI!");
         Destroy(this);
     }
 }
示例#5
0
        public override void OptionsPane()
        {
            // GUILayout.BeginArea(optionArea);
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginVertical();

            xmlFilePath = FixPath(ReplayGUI.TextField(xmlFilePath, "XML File Path"));

            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            //GUILayout.EndArea();
        }
        void OnGUI()
        {
            if (!string.IsNullOrEmpty(sqlErrorString))
            {
                GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "");
                GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
                GUILayout.BeginVertical();

                GUILayout.Label("There was an SQL error:\n" + sqlErrorString);
                if (ReplayGUI.Button("OK"))
                {
                    sqlErrorString = null;
                }

                GUILayout.EndVertical();
                GUILayout.EndArea();
            }
        }
 void CommandGUI()
 {
     directEditCommString = ReplayGUI.ToggleField(directEditCommString, "Direct Edit Command String", 2, 1);
     if (directEditCommString)
     {
         bool bak = GUI.enabled;
         GUI.enabled &= !lockSelect;
         selectClause = ReplayGUI.BigTextField(selectClause, "SELECT", 4, 1);
         GUI.enabled  = bak;
         lockSelect   = ReplayGUI.ToggleField(lockSelect, lockSelect ? "unlock" : "lock", 1, 2);
         fromClause   = ReplayGUI.BigTextField(fromClause, "FROM", 4, 1);
         whereClause  = ReplayGUI.BigTextField(whereClause, "WHERE", 4, 1);
         otherClauses = ReplayGUI.BigTextField(otherClauses, "misc", 4, 1);
     }
     else
     {
         ReplayGUI.Label("I haven't setup indirect command editing yet", 3, 1);
     }
 }
        private void ConnectionGUI()
        {
            bool before = directEditConnString;

            directEditConnString = ReplayGUI.ToggleField(directEditConnString, "Direct Edit Connection String", 2, 1);

            if (before && !directEditConnString)
            {
                ParseConnString(ConnectionString);
            }

            if (directEditConnString)
            {
                ConnectionString = ReplayGUI.BigTextField(ConnectionString, "Connection", 4, 1);
            }
            else
            {
                server   = ReplayGUI.TextField(server, "Server Name", 2, 1);
                portNum  = ReplayGUI.TextField(portNum, "Port Number", 2, 1);
                database = ReplayGUI.TextField(database, "Database Name", 2, 1);
                userID   = ReplayGUI.TextField(userID, "User ID", 2, 1);

                //The password for the DB
                if (!showPassword)
                {
                    password = ReplayGUI.PasswordField(password, "Password", 2, 1);
                }
                else
                {
                    password = ReplayGUI.TextField(password, "Password", 2, 1);
                }

                showPassword = ReplayGUI.ToggleField(showPassword, showPassword ? "hide password" : "show password", 1, 4);

                ConnectionString = System.String.Format("Server={0};Port={1};Database={2};Uid={3};password={4}",
                                                        server,
                                                        portNum,
                                                        database,
                                                        userID,
                                                        password);
            }
        }
        public override void OptionsPane()
        {
            // GUILayout.BeginArea(optionArea);
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginVertical();

            //   float bWidth = ReplayGUI.standardButtonWidth;
            //  float bHeight = ReplayGUI.standardButtonHeight;

            connOptionsOpen = ReplayGUI.ExpandButton(connOptionsOpen, "Connection Settings");
            if (connOptionsOpen)
            {
                ConnectionGUI();
            }

            ReplayGUI.Label("Command Settings");
            CommandGUI();

            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            //  GUILayout.EndArea();
        }
示例#10
0
 public override void OptionsPane()
 {
     ReplayGUI.Label("THIS MENU IS PROBABLY OUT OF DATE USE THE INSPECTOR FOR NOW.");
 }
示例#11
0
        private void CacheUserLogs()
        {
            MySqlCommand command = conn.CreateCommand();

            if (string.IsNullOrEmpty(db_where_clause))
            {
                command.CommandText = String.Format("SELECT selection, action, input, state, eventTime, userID, levelName, attemptNumber, sessionID, transactionID, attemptID FROM {0} WHERE userID=\"{1}\" ORDER BY eventTime;", db_table, cached_users[current_user_dex]);
            }
            else
            {
                string where        = string.Format("userID = \"{0}\" AND {1}", cached_users[current_user_dex], db_where_clause);
                command.CommandText = String.Format("SELECT selection, action, input, state, eventTime, userID, levelName, attemptNumber, sessionID, transactionID, attemptID FROM {0} WHERE {1} ORDER BY eventTime;", db_table, where);
            }

            try {
                conn.Open();
            }
            catch (Exception ex) {
                Debug.LogException(ex);
                ReplayGUI.ErrorMessage(string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
            }
            Debug.LogFormat("<color=purple>MySQL Query:</color> {0}", command.CommandText);
            MySqlDataReader reader = command.ExecuteReader();

            cached_actions = new List <AgentAction>();
            while (reader.Read())
            {
                AgentAction act = new AgentAction(
                    reader["selection"].ToString(),
                    reader["action"].ToString(),
                    reader["input"].ToString(),
                    reader["state"].ToString(),
                    reader["eventTime"].ToString(),
                    reader["userID"].ToString(),
                    reader["levelName"].ToString(),
                    reader["attemptNumber"].ToString(),
                    reader["sessionID"].ToString(),
                    reader["transactionID"].ToString(),
                    reader["attemptID"].ToString());
                cached_actions.Add(act);
            }

            conn.Close();

            Debug.LogFormat("Cached {0} actions for user {1}", cached_actions.Count, cached_users[current_user_dex]);

            cached_actions_by_level = new Dictionary <string, List <int> >();
            for (int i = 0; i < cached_actions.Count; i++)
            {
                AgentAction act = cached_actions[i];
                if (act.Action == "Level_Start")
                {
                    continue;
                }
                if (!cached_actions_by_level.ContainsKey(act.LevelName))
                {
                    cached_actions_by_level.Add(act.LevelName, new List <int>());
                }
                cached_actions_by_level[act.LevelName].Add(i);
            }
            current_action_dex = -1;
            FireEvent(EventTypes.User_Changed);
        }
示例#12
0
        void StandardOptions()
        {
            //   GUILayout.BeginArea(mainOptionsRect);
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUILayout.BeginVertical();

            Application.targetFrameRate = ReplayGUI.IntField(Application.targetFrameRate, "Target Frame Rate", "Set the Application.targetFrameRate, may help improve parity between the replay result and the original recorded data. A value of -1 runs at full speed.");
            Application.runInBackground = ReplayGUI.ToggleField(Application.runInBackground, "Run Unity in Background", "If checked Unity will continue to run if the editor loses focus.", 2);
            rae.ExitOnDone    = ToggleField(rae.ExitOnDone, "Exit play mode when done", "The RAE will automatically exit playmode when the log reader has run out of logs.", 2);
            rae.stopCondition = EnumField <ReplayAnalysisEngine.StoppingCondition>(rae.stopCondition, "Stopping Mode", "Controls the conditions that RAE will use to decide when to stop action simulation before running the interpreter.");

            switch (rae.stopCondition)
            {
            case ReplayAnalysisEngine.StoppingCondition.Instant:
                break;

            case ReplayAnalysisEngine.StoppingCondition.WaitForStop:
            case ReplayAnalysisEngine.StoppingCondition.TimeOut:
            case ReplayAnalysisEngine.StoppingCondition.Simulate:
            case ReplayAnalysisEngine.StoppingCondition.Custom:
                rae.TimeAcceleration = ReplayGUI.FloatField(rae.TimeAcceleration, "Time Acceleration", "The multiplier applied to Unity's Time.timescale when running an action.", 1);
                rae.TimeOut          = ReplayGUI.FloatField(rae.TimeOut, "Time Out", "The number of scaled seconds to wait before forcing the RAE to advance to the next action.", 1);
                break;
            }
            //rae.ReplayMode = ReplayGUI.EnumField<ReplayAnalysisEngine.IterationMode>(rae.ReplayMode, "Iteration Mode:", "Whether to iterate action-by-action or only the final action in any attempt.");
            rae.PauseAfter    = ReplayGUI.IntField((int)rae.PauseAfter, "Pause After N Actions", "The RAE will pause itself after every N actions. A value of <= 0 will never pause.");
            rae.runReportPath = ReplayGUI.TextField(rae.runReportPath, "Report Directory", "The path where the run report of this replay run will be saved.");

            rae.ScreenShotTiming = EnumField <ReplayAnalysisEngine.ScreenShotTimingOption>(rae.ScreenShotTiming, "Screenshot Setting:", "Change if and when the RAE should take screenshots while processing.", .8f, 0);
            switch (rae.ScreenShotTiming)
            {
            case ReplayAnalysisEngine.ScreenShotTimingOption.Disabled:
                break;

            default:
                rae.ScreenShotMode      = ReplayGUI.EnumField <ReplayAnalysisEngine.ScreenShotModeOption>(rae.ScreenShotMode, "Screenshot Mode:", "Which screenshot mode you want to use, JPG will not include a watermark.", 1, 1);
                rae.screenshotDirectory = ReplayGUI.TextField(rae.screenshotDirectory, "Screenshot Directory", 4, 1);
                //if (this.writer is TabDelimitedTextFileWriter) {
                //    switch (ReplayGUI.YesNo("Would you like to copy the log path from the AnalysisWriter?",.5f,1)) {
                //        case YesNoResponse.Yes:
                //            rae.screenshotDirectory = (this.writer as TabDelimitedTextFileWriter).logPath;
                //            this.writer = null;
                //            break;
                //        case YesNoResponse.No:
                //            this.writer = null;
                //            break;
                //        default:
                //            break;
                //    }
                //}
                if (!string.IsNullOrEmpty(rae.screenshotDirectory) && !Directory.Exists(rae.screenshotDirectory))
                {
                    switch (ReplayGUI.YesNo("The screenshot path does not exist would you like to create it?", .5f, 1))
                    {
                    case YesNoResponse.Yes:
                        Directory.CreateDirectory(rae.screenshotDirectory);
                        break;

                    case YesNoResponse.No:
                        rae.screenshotDirectory = string.Empty;
                        break;

                    default:
                        break;
                    }
                }
                break;
            }

            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            // GUILayout.EndArea();
        }
示例#13
0
        /// <summary>
        /// Draws the additional options GUI.
        /// </summary>
        void MainGUI(int windowID)
        {
            //draw the toolbar
            GUILayout.BeginVertical();

            //put the running buttons here
            GUILayout.BeginHorizontal();
            if (ReplayGUI.Button(rae.Initialized ? "Next Action" : "Initialize", rae.Initialized ? "Step to the next action in the logs" : "Initialize all of the RAE's components. This much be done before running."))
            {
                if (!rae.Initialized)
                {
                    rae.Initialize();
                }
                else
                {
                    rae.StepNextAction();
                }
            }

            bakEnabled  = GUI.enabled;
            GUI.enabled = rae.Initialized;
            if (ReplayGUI.Button(rae.Running ? "Pause" : "Run", rae.Running ? "Pause the run after the next action is complete." : "Begin running the simulation where here."))
            {
                if (rae.Running)
                {
                    rae.Pause();
                }
                else
                {
                    rae.Run();
                }
            }

            GUI.enabled = bakEnabled;

            if (ReplayGUI.Button("Close", "Close the RAE Options. You can bring it back up with:" + displayCombo.InputString))
            {
                this.menuUp = false;
            }

            GUILayout.Space(standardButtonWidth / 8);
            GUILayout.Label(string.Format("Current Scene: {0}", SceneManager.GetActiveScene().name));

            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Options");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            currentOption = GUILayout.Toolbar(currentOption, this.optionNames, GUILayout.Width(standardButtonWidth * optionNames.Length), GUILayout.Height(standardButtonHeight));

            if (currentOption == 0)
            {
                StandardOptions();
            }
            else
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                GUILayout.BeginVertical();
                raeComponents[currentOption].OptionsPane();
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            }

            GUILayout.Label(GUI.tooltip);

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
 void Start()
 {
     mainGUI = GetComponent <ReplayGUI>();
 }
        public override void OptionsPane()
        {
            if (mainGUI == null)
            {
                mainGUI = GetComponent <ReplayGUI>();
            }


            // GUILayout.BeginArea(layoutRect);
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginVertical();
            GUILayout.Label("Action Filtering");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            int removeDex = -1;

            for (int i = 0; i < skipActionTypes.Count; i++)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("-", GUILayout.Width(charButtonWidth), GUILayout.Height(ReplayGUI.standardButtonHeight)))
                {
                    removeDex = i;
                }
                skipActionTypes[i] = GUILayout.TextField(skipActionTypes[i], GUILayout.Width(ReplayGUI.standardButtonWidth * 2), GUILayout.Height(ReplayGUI.standardButtonHeight));
                GUILayout.EndHorizontal();
            }
            if (removeDex >= 0)
            {
                skipActionTypes.RemoveAt(removeDex);
            }

            GUILayout.Space(ReplayGUI.standardButtonHeight / 2);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("+", GUILayout.Width(charButtonWidth), GUILayout.Height(ReplayGUI.standardButtonHeight)))
            {
                AddSkipActionType(NEW_TYPE);
            }
            bool bak = GUI.enabled;

            GUI.enabled = false;
            GUILayout.TextField(NEW_TYPE, GUILayout.Width(ReplayGUI.standardButtonWidth * 3), GUILayout.Height(ReplayGUI.standardButtonHeight));
            GUI.enabled = bak;
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.Space(ReplayGUI.standardButtonWidth / 2);

            GUILayout.BeginVertical();
            if (seeActionTypes.Count == 0)
            {
                GUILayout.Label("No Actions Seen Yet.", GUILayout.Width(ReplayGUI.standardButtonWidth * 3), GUILayout.Height(ReplayGUI.standardButtonHeight));
            }
            else
            {
                foreach (string s in seeActionTypes.Keys)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("<", GUILayout.Width(charButtonWidth), GUILayout.Height(ReplayGUI.standardButtonHeight)))
                    {
                        AddSkipActionType(s);
                    }
                    GUILayout.Label(s + " : " + seeActionTypes[s], GUILayout.Width(ReplayGUI.standardButtonWidth * 3), GUILayout.Height(ReplayGUI.standardButtonHeight));
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            //GUILayout.EndArea();
        }
 /// <summary>
 /// This function is used to draw the in-engine options menu for the
 /// component. It will be called within the context of a GUILayout.Window
 /// after a GUILayout.BeginVertical() call. The GUILayout.EndVertical()
 /// will be managed in the calling context after returning from this
 /// functions.
 /// </summary>
 public virtual void OptionsPane()
 {
     ReplayGUI.Label(string.Format("No options provided for {0} component", GUIName));
 }