Пример #1
0
    public void DrawComposedSubActivities(ComposedActivity activity)
    {
        #region DRAWS LANE
        Matrix4x4 backupMatrix = GUI.matrix;
        Rect poolRect = new Rect(0, 15, Screen.width-40, 300);
        GUI.Box(poolRect, "", "Lane");

        GUIUtility.RotateAroundPivot(270f, new Vector2(0, 300+15));
        GUI.Button(new Rect(0, 300+15, 300, 30), "Activity " + activity.PrID + ": " + activity.Name, "PoolLabel");
        GUI.matrix = backupMatrix;
        #endregion
        #region DRAWS EDGE FLOWS
        foreach (Flow flow in activity.Connections)
        {
            Primitive source = Manager.GameState.GetSubPrimitive(Manager.CurrentProcess.PID,
                (Manager.CurrentScreen == GameManager.GameScreen.ComposedCreation ||
                Manager.CurrentScreen == GameManager.GameScreen.ViewComposed) ? -1 : Manager.CurrentVersion.PVID,
                Manager.CurrentLane.PrID,
                Manager.InspectorPrimitive.PrID, flow.SourceID);
            Primitive target = Manager.GameState.GetSubPrimitive(Manager.CurrentProcess.PID,
                (Manager.CurrentScreen == GameManager.GameScreen.ComposedCreation ||
                Manager.CurrentScreen == GameManager.GameScreen.ViewComposed) ? -1 : Manager.CurrentVersion.PVID,
                Manager.CurrentLane.PrID,
                Manager.InspectorPrimitive.PrID, flow.TargetID);

            if (source is Event && ((Event)source).categ.Equals(Event.Categ.Start))
                DrawLine(flow, Color.black, 3, true, false, activity.PrID, activity.PrID);

            else if (target is Event && ((Event)target).categ.Equals(Event.Categ.End))
                DrawLine(flow, Color.black, 3, false, true, activity.PrID, activity.PrID);

            else if (source is Event && ((Event)source).categ.Equals(Event.Categ.Merge))
                DrawLine(flow, Color.black, 3, true, false, activity.PrID, activity.PrID);
            else if (target is Event && ((Event)target).categ.Equals(Event.Categ.Merge))
                DrawLine(flow, Color.black, 3, false, true, activity.PrID, activity.PrID);
            else
                DrawLine(flow, Color.black, 3, false, false, activity.PrID, activity.PrID);
        }
        #endregion
        #region DRAWS LANGUAGE PRIMITIVES
        foreach (Primitive prim in activity.lane.Elements)
        {
            Rect primitiveRect = new Rect(prim.x-75, prim.y-25, 150, 50);

            #region Drop
            if (prim.dragging && Input.GetMouseButtonUp(1) && EnableProcessEdition)
            {
                prim.dragging = false;

                if (!poolRect.Contains(new Vector2(prim.x, prim.y)))
                {
                    prim.x = oldPrimitivePos.x;
                    prim.y = oldPrimitivePos.y;
                }
                else
                    Mechanics.RepositionSubPrimitive(Manager.CurrentProcess.PID,
                        Manager.CurrentScreen == GameManager.GameScreen.ComposedCreation ? -1 : Manager.CurrentVersion.PVID,
                        activity.PrID, prim.PrID, prim.x, prim.y);
            }
            #endregion
            #region Drag
            else if (primitiveRect.Contains(UnityEngine.Event.current.mousePosition) &&
                Input.GetMouseButtonDown(1) && !flowMode && EnableProcessEdition)
            {
                oldPrimitivePos = new Vector2(prim.x, prim.y);
                prim.dragging = true;
            }
            #endregion
            #region Moving position
            if (prim.dragging && EnableProcessEdition)
            {
                Vector3 dropPosition = Input.mousePosition;
                prim.x = dropPosition.x-15;
                prim.y = Screen.height-dropPosition.y-80;
            }
            #endregion

            string primStyle = "";

            if (prim is Activity)
            {
                Activity a = prim as Activity;

                if (prim.PrID == Manager.InspectorSubPrimitive.PrID ||
                    (clickSource != null && prim.PrID == clickSource.PrID) ||
                    (clickTarget != null && prim.PrID == clickTarget.PrID) && EnableProcessEdition)
                    primStyle = "ActivitySel";
                else
                    primStyle = "Activity";

                if (GUI.Button(primitiveRect, a.Name, primStyle))
                {
                    PaintEditName.changeCondition = PaintEditName.changeName = PaintEditName.changeSubName = false;
                    Manager.InspectorSubPrimitive = a;
                    subPrimitiveName = a.Name;

                    if (flowMode && !determinedSource)
                    {
                        clickSource = a;
                        determinedSource = true;
                    }
                    else if (flowMode && determinedSource)
                    {
                        clickTarget = a;
                        determinedFlow = true;
                        determinedSource = false;
                    }
                }

                if (primitiveRect.Contains(UnityEngine.Event.current.mousePosition) &&
                    (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) &&
                    Input.GetMouseButtonUp(0) && EnableProcessEdition)
                {
                    if (Manager.InspectorSubPrimitive is Activity)
                    {
                        PaintEditName.changeSubName = false;
                        Manager.InspectorSubPrimitive = a;
                        Activity subActivity = Manager.InspectorSubPrimitive as Activity;
                        subPrimitiveName = subActivity.Name;
                        PaintEditName.changeSubName = true;
                        PaintEditName.primitiveRect = primitiveRect;
                    }
                }

                if (UnityEngine.Event.current.type == EventType.KeyUp &&
                    UnityEngine.Event.current.keyCode == KeyCode.Delete &&
                    prim.PrID == Manager.InspectorSubPrimitive.PrID && EnableProcessEdition)
                {
                    LanguageConstructor.RemoveSubPrimitive(Manager.CurrentProcess.PID,
                        Manager.CurrentScreen == GameManager.GameScreen.ComposedCreation ? -1 : Manager.CurrentVersion.PVID,
                        Manager.CurrentLane.PrID,
                        Manager.InspectorPrimitive.PrID, Manager.InspectorSubPrimitive.PrID);
                }
            }
            else if (prim is Event)
            {
                Event e = prim as Event;

                if (e.categ.Equals(Event.Categ.Start))
                {
                    if (prim.PrID == Manager.InspectorSubPrimitive.PrID ||
                        (clickSource != null && prim.PrID == clickSource.PrID) ||
                        (clickTarget != null && prim.PrID == clickTarget.PrID) && EnableProcessEdition)
                        primStyle = "StartSel";
                    else
                        primStyle = "StartEvent";
                }
                else if (e.categ.Equals(Event.Categ.End))
                {
                    if (prim.PrID == Manager.InspectorSubPrimitive.PrID ||
                        (clickSource != null && prim.PrID == clickSource.PrID) ||
                        (clickTarget != null && prim.PrID == clickTarget.PrID) && EnableProcessEdition)
                        primStyle = "EndSel";
                    else
                        primStyle = "EndEvent";
                }
                else if (e.categ.Equals(Event.Categ.Merge))
                {
                    if (prim.PrID == Manager.InspectorSubPrimitive.PrID ||
                        (clickSource != null && prim.PrID == clickSource.PrID) ||
                        (clickTarget != null && prim.PrID == clickTarget.PrID) && EnableProcessEdition)
                        primStyle = "MergeSel";
                    else
                        primStyle = "Merge";
                }

                if (GUI.Button(new Rect(e.x-20, e.y-20, 40, 40), "", primStyle))
                {
                    Manager.InspectorSubPrimitive = e;

                    if (flowMode && !determinedSource)
                    {
                        clickSource = e;
                        determinedSource = true;
                    }
                    else if (flowMode && determinedSource)
                    {
                        clickTarget = e;
                        determinedFlow = true;
                        determinedSource = false;
                    }
                }

                if (UnityEngine.Event.current.type == EventType.KeyUp &&
                    UnityEngine.Event.current.keyCode == KeyCode.Delete &&
                    prim.PrID == Manager.InspectorSubPrimitive.PrID && EnableProcessEdition)
                {
                    if (e.categ.Equals(Event.Categ.Merge))
                        LanguageConstructor.RemoveSubPrimitive(Manager.CurrentProcess.PID,
                            Manager.CurrentScreen == GameManager.GameScreen.ProcessCreation ? -1 : Manager.CurrentVersion.PVID,
                            Manager.CurrentLane.PrID,
                            Manager.InspectorPrimitive.PrID, Manager.InspectorSubPrimitive.PrID);
                    else if (e.categ.Equals(Event.Categ.Start))
                        Manager.Notifications.Items.Add(
                            new Notification(Notification.Type.Exception, "You cannot delete a start event."));
                    else if (e.categ.Equals(Event.Categ.End))
                        Manager.Notifications.Items.Add(
                            new Notification(Notification.Type.Exception, "You cannot delete an end event."));
                }
            }
        }
        #endregion
    }
Пример #2
0
    public void NewComposedActivity(string player, int PID, int PVID, int LaneID, int PrID, string name, float x, float y)
    {
        try
        {
            Process process = GetTargetProcess(PID, PVID);
            ComposedActivity activity;

            if (PrID == -1)
                activity = new ComposedActivity();
            else
                activity = new ComposedActivity(PrID, name);

            Lane lane = State.GetLane(PID, PVID, LaneID);

            if (x == -1)
            {
                if (lane.Elements.Count == 0)
                {
                    activity.x = 200;
                    activity.y = 180*process.Pool.Count-90;
                }
                else if (lane.Elements[lane.Elements.Count-1] is Event &&
                    !(lane.Elements[lane.Elements.Count-1] as Event).categ.Equals(Event.Categ.Merge))
                {
                    activity.x = 200;
                    activity.y = lane.Elements[lane.Elements.Count-1].y;
                }
                else
                {
                    activity.x = lane.Elements[lane.Elements.Count-1].x + 170;
                    activity.y = lane.Elements[lane.Elements.Count-1].y;
                }
            }
            else
            {
                activity.x = x;
                activity.y = y;
            }

            lane.Elements.Add(activity);

            networkView.RPC("NewComposedActivityAck", RPCMode.Others, "Success", player, PID, PVID, LaneID,
                activity.PrID, activity.Name, activity.x, activity.y, false);
            Console.Log.Add("<b>Added composed activity</b> to process " + PID + ".");
        }
        catch (InvalidOperationException ioe)
        {
            Debug.Log(ioe.StackTrace);
            networkView.RPC("NewComposedActivityAck", RPCMode.Others, "Failure", player, PID, PVID, LaneID, -1, -1, "", (float)-1, (float)-1, false);
        }
    }
Пример #3
0
	public void NewComposedActivityAck(string status, string player, int PID, int PVID, int LaneID, int PrID, string name,
		float x, float y, bool update)
	{
		try
		{
			ValidateAcknowledge(status, IOExceptions[5]);
			if (!ProcessExists(PID, PVID) || (update && !Painter.UpdateMode))
				return;
			
			Lane lane = Painter.Manager.GameState.GetLane(PID, PVID, LaneID);
			ComposedActivity activity = new ComposedActivity(PrID, name, x, y);
			
			lane.Elements.Add(activity);
			Painter.Manager.InspectorPrimitive = activity;
			
			if (!Painter.UpdateMode && activity.lane.Elements.Count < 2)
			{
				LanguageConstructor.AddEventComposed(PID, PVID, LaneID, PrID, "Start");
				LanguageConstructor.AddEventComposed(PID, PVID, LaneID, PrID, "End");
			}
		}
		catch (InvalidOperationException ioe) 
		{
			Debug.Log(ioe.StackTrace);
		}
	}
Пример #4
0
    public void DrawComposedSubActivities(ComposedActivity activity)
    {
        int PVID = (Server.CurrentScreen == Server.GameScreen.ViewProcess || Server.CurrentVersion == null) ?
            -1 : Server.CurrentVersion.PVID;

        GUI.BeginGroup(new Rect(15, 80, Server.SCREEN_WIDTH, Server.SCREEN_HEIGHT-100));

        #region DRAWS LANE
        Matrix4x4 backupMatrix = GUI.matrix;
        Rect poolRect = new Rect(0, 15, Server.SCREEN_WIDTH-40, 300);
        GUI.Box(poolRect, "", "Lane");
        GUIUtility.RotateAroundPivot(270f, new Vector2(0, 300+15));
        GUI.Button(new Rect(0, 300+15, 300, 30), "Activity " + activity.PrID + ": " + activity.Name, "PoolLabel");
        GUI.matrix = backupMatrix;
        #endregion

        #region DRAWS EDGE FLOWS
        foreach (Flow flow in activity.Connections)
        {
            int LaneID = Server.State.GetLaneID(Server.CurrentProcess.PID, PVID, activity.PrID);
            Primitive source = Server.State.GetSubPrimitive(Server.CurrentProcess.PID, PVID, LaneID,
                Server.CurrentPrimitive.PrID, flow.SourceID);
            Primitive target = Server.State.GetSubPrimitive(Server.CurrentProcess.PID, PVID, LaneID,
                Server.CurrentPrimitive.PrID, flow.TargetID);

            if (source is Event && ((Event)source).categ.Equals(Event.Categ.Start))
                DrawLine(flow, Color.black, 3, true, false, activity.PrID, activity.PrID);

            else if (target is Event && ((Event)target).categ.Equals(Event.Categ.End))
                DrawLine(flow, Color.black, 3, false, true, activity.PrID, activity.PrID);

            else if (source is Event && ((Event)source).categ.Equals(Event.Categ.Merge))
                DrawLine(flow, Color.black, 3, true, false, activity.PrID, activity.PrID);
            else if (target is Event && ((Event)target).categ.Equals(Event.Categ.Merge))
                DrawLine(flow, Color.black, 3, false, true, activity.PrID, activity.PrID);
            else
                DrawLine(flow, Color.black, 3, false, false, activity.PrID, activity.PrID);
        }
        #endregion

        #region DRAWS LANGUAGE PRIMITIVES
        foreach (Primitive prim in activity.lane.Elements)
        {
            Rect primitiveRect = new Rect(prim.x-75, prim.y-25, 150, 50);

            string primStyle;

            if (prim is Activity)
            {
                Activity a = prim as Activity;

                if (Server.CurrentSubPrimitive != null && prim.PrID == Server.CurrentSubPrimitive.PrID)
                    primStyle = "ActivitySel";
                else
                    primStyle = "Activity";

                if (GUI.Button(primitiveRect, a.Name, primStyle))
                    Server.CurrentSubPrimitive = a;
            }
            else if (prim is Event)
            {
                Event e = prim as Event;

                if (e.categ.Equals(Event.Categ.Start))
                {
                    if (Server.CurrentSubPrimitive != null && prim.PrID == Server.CurrentSubPrimitive.PrID)
                        primStyle = "StartSel";
                    else
                        primStyle = "StartEvent";
                }
                else if (e.categ.Equals(Event.Categ.End))
                {
                    if (Server.CurrentSubPrimitive != null && prim.PrID == Server.CurrentSubPrimitive.PrID)
                        primStyle = "EndSel";
                    else
                        primStyle = "EndEvent";
                }
                else if (e.categ.Equals(Event.Categ.Merge))
                {
                    if (Server.CurrentSubPrimitive != null && prim.PrID == Server.CurrentSubPrimitive.PrID)
                        primStyle = "MergeSel";
                    else
                        primStyle = "Merge";
                }
                else primStyle = "";

                if (GUI.Button(new Rect(e.x-20, e.y-20, 40, 40), "", primStyle))
                    Server.CurrentSubPrimitive = e;
            }
        }
        #endregion

        GUI.EndGroup();
    }