Ejemplo n.º 1
0
    public void Start()
    {
        //SpellCreator.Event e = EventSaver.LoadEventAsXML(testeventname);
        //e.Execute();

        SpellCreator.Event ev = EventSaver.LoadEventAsObject(testeventname);
        ev.Execute();
    }
Ejemplo n.º 2
0
    static void AddActionWindow()
    {
        if (editingEvent == null)
        {
            addActionClicked = false;
            Debug.LogWarning("The event you are trying to add to is null");
        }
        else if (editingEvent.eventName == null)
        {
            addActionClicked = false;
            Debug.LogWarning("The event you are trying to add to is null");
        }

        GUILayout.Label("Add Action", "boldLabel");


        List <string>      options = new List <string>();
        List <System.Type> types   = ActionTracker.FindActions();

        foreach (System.Type type in types)
        {
            options.Add(type.Name);
        }
        selectedNewAction = EditorGUILayout.Popup("Action to Add", selectedNewAction, options.ToArray());
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Cancel"))
        {
            addActionClicked = false;
        }
        if (GUILayout.Button("Add Action"))
        {
            addActionClicked = false;
            Action newAction = null;

            //TODO: automatically create the object?
            newAction = (Action)AssetDatabase.LoadAssetAtPath(EventSaver.TOOL_DATA_DIR + options[selectedNewAction] + ".asset", typeof(ScriptableObject));
            if (newAction == null)
            {
                Debug.LogError("Could not load asset at: " + EventSaver.TOOL_DATA_DIR + options[selectedNewAction]);
            }

            newAction = ScriptableObject.Instantiate(newAction);//DISCUSS: memory leak or auto-collected?
            editingEvent.AddAction(newAction);
            Debug.Log("Created Action: " + newAction.ToString());

            EventSaver.SaveEventAsObject(editingEvent);
        }
        GUILayout.EndHorizontal();
    }
Ejemplo n.º 3
0
    public static void CreateEvent(string _name)
    {
        // make sure to save old, shouldn't be neccessary anymore
        if (editingEvent != null)
        {
            if (editingEvent.eventName != null)
            {
                EventSaver.SaveEventAsObject(editingEvent);
            }
        }

        editingEvent           = ScriptableObject.CreateInstance <SpellCreator.Event>();
        editingEvent.eventName = _name;

        EventSaver.SaveEventAsObject(editingEvent);
        createEventText = "";

        //FIX Make the new event the selected event
    }
Ejemplo n.º 4
0
    void OnGUI()
    {
        if (upIcon == null)
        {
            upIcon = (Texture)AssetDatabase.LoadAssetAtPath(IconPath + "upIcon.png", typeof(Texture));
        }
        if (downIcon == null)
        {
            downIcon = (Texture)AssetDatabase.LoadAssetAtPath(IconPath + "downIcon.png", typeof(Texture));
        }


        scrollPos = GUILayout.BeginScrollView(scrollPos);


        GUILayout.Label("Event", "boldLabel");

        //Select Event
        var directory = new DirectoryInfo(EventSaver.SAVED_DATA_DIR);
        var files     = directory.GetFiles();

        if (files.Length > 0)
        {
            //FIX Move this outside OnGui()

            List <string> options = new List <string>();

            string[] guids = AssetDatabase.FindAssets("t:Event", new string[] { EventSaver.SAVED_DATA_DIR.TrimEnd('/') });;
            foreach (string guid in guids)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(guid);
                options.Add(assetPath.Replace(EventSaver.SAVED_DATA_DIR, "").Replace(".asset", ""));
            }



            selectedEvent = EditorGUILayout.Popup("Event:", selectedEvent, options.ToArray());

            if (editingEvent == null)
            {
                editingEvent = EventSaver.LoadEventAsObject(options[selectedEvent]);
            }
            else if (editingEvent.eventName != options[selectedEvent])
            {
                editingEvent = EventSaver.LoadEventAsObject(options[selectedEvent]);
            }
            //FIX Save selected to file for later
        }


        if (editingEvent != null)
        {
            GUILayout.Label("Path: " + EventSaver.SAVED_DATA_DIR + editingEvent.eventName + ".asset");
        }

        //Create Event
        Separator(5, 2);
        createEventText = EditorGUILayout.TextField("New Event:", createEventText);
        if (GUILayout.Button("Create") && createEventText != "")
        {
            CreateEvent(createEventText);
        }



        //Actions
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); //Used as divider
        GUILayout.Label("Actions", "boldLabel");


        Separator(5, 2);
        if (editingEvent != null)
        {
            if (editingEvent.actions != null)
            {
                foreach (Action action in editingEvent.actions)
                {
                    if (action != null)
                    {
                        if (ActionWindow(action))
                        {
                            break;
                        }
                    }
                }
            }
        }

        //Add Action
        if (!addActionClicked)
        {
            if (GUILayout.Button("Add Action"))
            {
                addActionClicked = true;
            }
        }
        else
        {
            if (editingEvent.actions != null)
            {
                AddActionWindow();
            }
        }


        GUILayout.EndScrollView();
    }
Ejemplo n.º 5
0
        void Initialize()
        {
            try
            {
                NLog.LogManager.EnableLogging();

                _sdkLogger = new NLogWrapper();
                _log       = new Logger(nameof(HideezService), _sdkLogger);

                _log.WriteLine($">>>>>> Starting service");

                _log.WriteLine($"Service Version: {Assembly.GetEntryAssembly().GetName().Version}");
                _log.WriteLine($"CLR Version: {Environment.Version}");
                _log.WriteLine($"OS: {Environment.OSVersion}");
                _log.WriteLine($"Command: {Environment.CommandLine}");

                _log.WriteLine($">>>>> Starting messaging hub");
                var pubSubLogger = new MetaPubSubLogger(_sdkLogger);
                _messenger = new MetaPubSub(pubSubLogger);

                _log.WriteLine(">>>>>> Get registry settings key");
                clientRootRegistryKey = HideezClientRegistryRoot.GetRootRegistryKey(true);

                _log.WriteLine(">>>>>> Initialize session monitor");
                _sessionInfoProvider = new SessionInfoProvider(_sdkLogger);

                _log.WriteLine(">>>>>> Initialize workstation id provider");
                _workstationIdProvider = new WorkstationIdProvider(clientRootRegistryKey, _sdkLogger);
                if (string.IsNullOrWhiteSpace(_workstationIdProvider.GetWorkstationId()))
                {
                    _workstationIdProvider.SaveWorkstationId(Guid.NewGuid().ToString());
                }

                _log.WriteLine(">>>>>> Initilize audit");
                var    commonAppData            = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                string auditEventsDirectoryPath = $@"{commonAppData}\Hideez\Service\WorkstationEvents\";
                _eventSaver = new EventSaver(_sessionInfoProvider, _workstationIdProvider, auditEventsDirectoryPath, _sdkLogger);

                _log.WriteLine(">>>>>> Initialize session timestamp monitor");
                var sessionTimestampPath = $@"{commonAppData}\Hideez\Service\Timestamp\timestamp.dat";
                _sessionTimestampLogger = new SessionTimestampLogger(sessionTimestampPath, _sessionInfoProvider, _eventSaver, _sdkLogger);

                OnServiceStarted();

                _log.WriteLine(">>>>>> Initialize SDK");
                InitializeSDK().Wait();

                _messenger.StartServer("HideezServicePipe", () =>
                {
                    try
                    {
                        _log.WriteLine("Custom pipe config started");
                        var pipeSecurity = new PipeSecurity();
                        pipeSecurity.AddAccessRule(new PipeAccessRule(
                                                       new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null),
                                                       PipeAccessRights.FullControl,
                                                       AccessControlType.Allow));

                        var pipe = new NamedPipeServerStream("HideezServicePipe", PipeDirection.InOut, 32,
                                                             PipeTransmissionMode.Message, PipeOptions.Asynchronous, 4096, 4096, pipeSecurity);

                        _log.WriteLine("Custom pipe config successful");
                        return(pipe);
                    }
                    catch (Exception ex)
                    {
                        _log.WriteLine("Custom pipe config failed.", ex);
                        return(null);
                    }
                });

                _log.WriteLine(">>>>>> Service started");
            }
            catch (Exception ex)
            {
                _log.WriteLine("Hideez Service has encountered an error during initialization." +
                               Environment.NewLine +
                               "The error must be resolved until service operation can be resumed. " +
                               Environment.NewLine +
                               "The service will not restart automatically.", ex, LogErrorSeverity.Fatal);

                // Exit code 0 prevents automatic service restart trigger on exit
                Environment.Exit(0);
            }
        }