Example #1
0
	public static int IndexOf(pb_Shortcut[] shortcuts, KeyCode k, EventModifiers e)
	{
		for(int i = 0; i < shortcuts.Length; i++)
		{
			if(shortcuts[i].key == k && shortcuts[i].eventModifiers == e)
				return i;
		}
		return -1;
	}
Example #2
0
        public static IEnumerable <pb_Shortcut> ParseShortcuts(string str)
        {
            // Initialize Defaults if no string argument passed, or string ain't right
            if (str == null || str.Length < 3)
            {
                return(DefaultShortcuts());
            }

            string[]      split     = str.Split('*');
            pb_Shortcut[] shortcuts = new pb_Shortcut[split.Length];

            for (int i = 0; i < shortcuts.Length; i++)
            {
                shortcuts[i] = new pb_Shortcut(split[i]);
            }

            return(shortcuts);
        }
	/**
	 *	\brief Returns a new Shortcut array containing the default values.
	 *	\returns The default Shortcut array.
	 */
	public static pb_Shortcut[] DefaultShortcuts()
	{
		pb_Shortcut[] shortcuts = new pb_Shortcut[13];

		int i = 0;
		shortcuts[i++] = new pb_Shortcut("Escape", "Exit to Top level mode.", KeyCode.Escape, 0);
/**/	shortcuts[i++] = new pb_Shortcut("Toggle Geometry Mode", "Enter or exit geometry edit mode.", KeyCode.G, 0);
/**/	shortcuts[i++] = new pb_Shortcut("Texture Mode", "Enter texture edit mode.", KeyCode.J, 0);
/**/	shortcuts[i++] = new pb_Shortcut("Toggle Selection Mode", "Toggles between vertex and face selection mode.", KeyCode.H, 0);
		shortcuts[i++] = new pb_Shortcut("Set Trigger", "Sets all selected objects to entity type Trigger.", KeyCode.T, 0);
		shortcuts[i++] = new pb_Shortcut("Set Occluder", "Sets all selected objects to entity type Occluder.", KeyCode.O, 0);
		shortcuts[i++] = new pb_Shortcut("Set Collider", "Sets all selected objects to entity type Collider.", KeyCode.C, 0);
		shortcuts[i++] = new pb_Shortcut("Set Mover", "Sets all selected objects to entity type Mover.", KeyCode.M, 0);
		shortcuts[i++] = new pb_Shortcut("Set Detail", "Sets all selected objects to entity type Brush.", KeyCode.B, 0);
		shortcuts[i++] = new pb_Shortcut("Toggle Handle Pivot", "Toggles the orientation of the ProBuilder selection handle.", KeyCode.P, 0);
		shortcuts[i++] = new pb_Shortcut("Quick Apply Nodraw", "When the Texture Window is open, this shortcut will apply the Nodraw material to every selected face.", KeyCode.N, 0);
		shortcuts[i++] = new pb_Shortcut("Delete Face", "Deletes all selected faces.", KeyCode.Backspace, EventModifiers.FunctionKey);
		shortcuts[i++] = new pb_Shortcut("Set Pivot", "Center pivot around current selection.", KeyCode.J, EventModifiers.Command);

		return shortcuts;
	}
Example #4
0
        public static pb_Shortcut[] ParseShortcuts(string str)
        {
            pb_Shortcut[] shortcuts;

            // Initialize Defaults if no string argument passed, or string ain't right
            if (str == null || str.Length < 3)
            {
                shortcuts = DefaultShortcuts();
            }
            else
            {
                string[] split = str.Split('*');
                shortcuts = new pb_Shortcut[split.Length];

                for (int i = 0; i < shortcuts.Length; i++)
                {
                    shortcuts[i] = new pb_Shortcut(split[i]);
                }
            }

            return(shortcuts);
        }
Example #5
0
        /**
         *	\brief Returns a new Shortcut array containing the default values.
         *	\returns The default Shortcut array.
         */
        public static pb_Shortcut[] DefaultShortcuts()
        {
            pb_Shortcut[] shortcuts = new pb_Shortcut[13];

            int i = 0;

            shortcuts[i++] = new pb_Shortcut("Escape", "Exit to Top level mode.", KeyCode.Escape, 0);
/**/ shortcuts[i++]        = new pb_Shortcut("Toggle Geometry Mode", "Enter or exit geometry edit mode.", KeyCode.G, 0);
/**/ shortcuts[i++]        = new pb_Shortcut("Texture Mode", "Enter texture edit mode.", KeyCode.J, 0);
/**/ shortcuts[i++]        = new pb_Shortcut("Toggle Selection Mode", "Toggles between vertex and face selection mode.", KeyCode.H, 0);
            shortcuts[i++] = new pb_Shortcut("Set Trigger", "Sets all selected objects to entity type Trigger.", KeyCode.T, 0);
            shortcuts[i++] = new pb_Shortcut("Set Occluder", "Sets all selected objects to entity type Occluder.", KeyCode.O, 0);
            shortcuts[i++] = new pb_Shortcut("Set Collider", "Sets all selected objects to entity type Collider.", KeyCode.C, 0);
            shortcuts[i++] = new pb_Shortcut("Set Mover", "Sets all selected objects to entity type Mover.", KeyCode.M, 0);
            shortcuts[i++] = new pb_Shortcut("Set Detail", "Sets all selected objects to entity type Brush.", KeyCode.B, 0);
            shortcuts[i++] = new pb_Shortcut("Toggle Handle Pivot", "Toggles the orientation of the ProBuilder selection handle.", KeyCode.P, 0);
            shortcuts[i++] = new pb_Shortcut("Quick Apply Nodraw", "When the Texture Window is open, this shortcut will apply the Nodraw material to every selected face.", KeyCode.N, 0);
            shortcuts[i++] = new pb_Shortcut("Delete Face", "Deletes all selected faces.", KeyCode.Backspace, EventModifiers.FunctionKey);
            shortcuts[i++] = new pb_Shortcut("Set Pivot", "Center pivot around current selection.", KeyCode.J, EventModifiers.Command);

            return(shortcuts);
        }
Example #6
0
	public static IEnumerable<pb_Shortcut> ParseShortcuts(string str)
	{
		// Initialize Defaults if no string argument passed, or string ain't right
		if(str == null || str.Length < 3)
			return DefaultShortcuts();

		string[] split = str.Split('*');
		pb_Shortcut[] shortcuts = new pb_Shortcut[split.Length];

		for(int i = 0; i < shortcuts.Length; i++)
			shortcuts[i] = new pb_Shortcut(split[i]);

		return shortcuts;
	}
Example #7
0
	public static string ShortcutsToString(pb_Shortcut[] shortcuts)
	{
		string val = "";
		for(int i = 0; i < shortcuts.Length; i++)
		{
			val += shortcuts[i].ToString();
			if(i!=shortcuts.Length-1)
				val += "*";
		}
		return val;
	}
	public static pb_Shortcut[] ParseShortcuts(string str)
	{
		pb_Shortcut[] shortcuts;
		
		// Initialize Defaults if no string argument passed, or string ain't right
		if(str == null || str.Length < 3)
		{
			shortcuts = DefaultShortcuts();
		}
		else
		{
			string[] split = str.Split('*');
			shortcuts = new pb_Shortcut[split.Length];

			for(int i = 0; i < shortcuts.Length; i++)
				shortcuts[i] = new pb_Shortcut(split[i]);
		}

		return shortcuts;
	}
Example #9
0
	private bool GeoLevelShortcuts(pb_Shortcut shortcut)
	{
		switch(shortcut.action)
		{
			case "Escape":
				ClearFaceSelection();
				pb_Editor_Utility.ShowNotification("Top Level");
				UpdateSelection(false);
				SetEditLevel(EditLevel.Top);
				return true;
		
			// TODO Remove once a workaround for non-upper-case shortcut chars is found			
			case "Toggle Selection Mode":

				if( pb_Preferences_Internal.GetBool(pb_Constant.pbUniqueModeShortcuts) )
					return false;

				ToggleSelectionMode();
				switch(selectionMode)
				{
					case SelectMode.Face:
						pb_Editor_Utility.ShowNotification("Editing Faces");
						break;

					case SelectMode.Vertex:
						pb_Editor_Utility.ShowNotification("Editing Vertices");
						break;

					case SelectMode.Edge:
						pb_Editor_Utility.ShowNotification("Editing Edges");
						break;
				}
				return true;
				
			#if !PROTOTYPE
			case "Delete Face":
				pb_Menu_Commands.MenuDeleteFace(selection);
				return true;
			#endif

			/* handle alignment */
			case "Toggle Handle Pivot":
				if(selectedVertexCount < 1)
					return false;

				if(editLevel != EditLevel.Texture)
				{		
					ToggleHandleAlignment();
					pb_Editor_Utility.ShowNotification("Handle Alignment: " + ((HandleAlignment)handleAlignment).ToString());
				}
				return true;

			case "Set Pivot":

		        if (selection.Length > 0)
		        {
					foreach (pb_Object pbo in selection)
					{
						pbUndo.RecordObjects(new Object[2] {pbo, pbo.transform}, "Set Pivot");

						if (pbo.SelectedTriangles.Length > 0)
						{
							pbo.CenterPivot(pbo.SelectedTriangles);
						}
						else
						{
							pbo.CenterPivot(null);
						}
					}
				}
				return true;

			default:
				return false;
		}
	}
Example #10
0
	private bool TopLevelShortcuts(pb_Shortcut shortcut)
	{
		if(selection == null || selection.Length < 1 || editLevel != EditLevel.Top)
			return false;

		switch(shortcut.action)
		{
			/* ENTITY TYPES */
			case "Set Trigger":
					pb_Menu_Commands.MenuSetEntityType(selection, EntityType.Trigger);
				return true;

			#if !PROTOTYPE
			case "Set Occluder":
					pb_Menu_Commands.MenuSetEntityType(selection, EntityType.Occluder);
				return true;
			#endif

			case "Set Collider":
					pb_Menu_Commands.MenuSetEntityType(selection, EntityType.Collider);
				return true;

			case "Set Mover":
					pb_Menu_Commands.MenuSetEntityType(selection, EntityType.Mover);
				return true;
				
			case "Set Detail":
					pb_Menu_Commands.MenuSetEntityType(selection, EntityType.Detail);
				return true;

			default:	
				return true;
		}
	}
Example #11
0
	private bool AllLevelShortcuts(pb_Shortcut shortcut)
	{
		bool uniqueModeShortcuts = pb_Preferences_Internal.GetBool(pb_Constant.pbUniqueModeShortcuts);
	
		switch(shortcut.action)
		{
			// TODO Remove once a workaround for non-upper-case shortcut chars is found
			case "Toggle Geometry Mode":

				if(editLevel == EditLevel.Geometry)
				{
					pb_Editor_Utility.ShowNotification("Top Level Editing");
					SetEditLevel(EditLevel.Top);
				}
				else if( !uniqueModeShortcuts )
				{
					pb_Editor_Utility.ShowNotification("Geometry Editing");
					SetEditLevel(EditLevel.Geometry);
				}
				return true;

			case "Vertex Mode":
			{
				if(!uniqueModeShortcuts)
					return false;

				if(editLevel == EditLevel.Top)	
					SetEditLevel(EditLevel.Geometry);

				SetSelectionMode( SelectMode.Vertex );
				return true;
			}

			case "Edge Mode":
			{
				if(!uniqueModeShortcuts)
					return false;
	
				if(editLevel == EditLevel.Top)	
					SetEditLevel(EditLevel.Geometry);

				SetSelectionMode( SelectMode.Edge );
				return true;
			}

			case "Face Mode":
			{
				if(!uniqueModeShortcuts)
					return false;

				if(editLevel == EditLevel.Top)	
					SetEditLevel(EditLevel.Geometry);

				SetSelectionMode( SelectMode.Face );
				return true;
			}

			default:
				return false;
		}
	}