Beispiel #1
0
		public override void initialize( Table table, Skin skin )
		{
			var button = new TextButton( _name, skin );
			button.onClicked += onButtonClicked;

			// we could have zero or 1 param
			var parameters = ( _memberInfo as MethodInfo ).GetParameters();
			if( parameters.Length == 0 )
			{
				table.add( button );
				return;
			}

			var parameter = parameters[0];
			_parameterType = parameter.ParameterType;

			_textField = new TextField( _parameterType.GetTypeInfo().IsValueType ? Activator.CreateInstance( _parameterType ).ToString() : "", skin );
			_textField.shouldIgnoreTextUpdatesWhileFocused = false;

			// add a filter for float/int
			if( _parameterType == typeof( float ) )
				_textField.setTextFieldFilter( new FloatFilter() );
			if( _parameterType == typeof( int ) )
				_textField.setTextFieldFilter( new DigitsOnlyFilter() );
			if( _parameterType == typeof( bool ) )
				_textField.setTextFieldFilter( new BoolFilter() );

			table.add( button );
			table.add( _textField ).setMaxWidth( 70 );
		}
Beispiel #2
0
		public override void initialize( Table table, Skin skin )
		{
			var label = createNameLabel( table, skin );
			_textField = new TextField( getValue<string>(), skin );
			_textField.setTextFieldFilter( new FloatFilter() );
			_textField.onTextChanged += ( field, str ) =>
			{
				setValue( str );
			};

			table.add( label );
			table.add( _textField ).setMaxWidth( 70 );
		}
Beispiel #3
0
		void setupTextField( Table table, Skin skin )
		{
			var label = createNameLabel( table, skin );
			_textField = new TextField( getValue<float>().ToString(), skin );
			_textField.setTextFieldFilter( new FloatFilter() );
			_textField.onTextChanged += ( field, str ) =>
			{
				float newValue;
				if( float.TryParse( str, out newValue ) )
					setValue( newValue );
			};

			table.add( label );
			table.add( _textField ).setMaxWidth( 70 );
		}
Beispiel #4
0
		public override void initialize( Table table, Skin skin )
		{
			var value = getValue<Vector2>();
			var label = createNameLabel( table, skin );

			var labelX = new Label( "x", skin );
			_textFieldX = new TextField( value.X.ToString(), skin );
			_textFieldX.setTextFieldFilter( new FloatFilter() ).setPreferredWidth( 50 );
			_textFieldX.onTextChanged += ( field, str ) =>
			{
				float newX;
				if( float.TryParse( str, out newX ) )
				{
					var newValue = getValue<Vector2>();
					newValue.X = newX;
					setValue( newValue );
				}
			};

			var labelY = new Label( "y", skin );
			_textFieldY = new TextField( value.Y.ToString(), skin );
			_textFieldY.setTextFieldFilter( new FloatFilter() ).setPreferredWidth( 50 );
			_textFieldY.onTextChanged += ( field, str ) =>
			{
				float newY;
				if( float.TryParse( str, out newY ) )
				{
					var newValue = getValue<Vector2>();
					newValue.Y = newY;
					setValue( newValue );
				}
			};

			var hBox = new HorizontalGroup( 5 );
			hBox.addElement( labelX );
			hBox.addElement( _textFieldX );
			hBox.addElement( labelY );
			hBox.addElement( _textFieldY );

			table.add( label );
			table.add( hBox );
		}
Beispiel #5
0
		public override void initialize( Table table, Skin skin )
		{
			var value = getValue<Color>();
			var label = createNameLabel( table, skin );

			var labelR = new Label( "r", skin );
			_textFieldR = new TextField( value.R.ToString(), skin );
			_textFieldR.setMaxLength( 3 );
			_textFieldR.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 );
			_textFieldR.onTextChanged += ( field, str ) =>
			{
				int newR;
				if( int.TryParse( str, out newR ) )
				{
					var newValue = getValue<Color>();
					newValue.R = (byte)newR;
					setValue( newValue );
				}
			};

			var labelG = new Label( "g", skin );
			_textFieldG = new TextField( value.G.ToString(), skin );
			_textFieldG.setMaxLength( 3 );
			_textFieldG.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 );
			_textFieldG.onTextChanged += ( field, str ) =>
			{
				int newG;
				if( int.TryParse( str, out newG ) )
				{
					var newValue = getValue<Color>();
					newValue.G = (byte)newG;
					setValue( newValue );
				}
			};

			var labelB = new Label( "b", skin );
			_textFieldB = new TextField( value.B.ToString(), skin );
			_textFieldB.setMaxLength( 3 );
			_textFieldB.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 );
			_textFieldB.onTextChanged += ( field, str ) =>
			{
				int newB;
				if( int.TryParse( str, out newB ) )
				{
					var newValue = getValue<Color>();
					newValue.B = (byte)newB;
					setValue( newValue );
				}
			};

			var labelA = new Label( "a", skin );
			_textFieldA = new TextField( value.A.ToString(), skin );
			_textFieldA.setMaxLength( 3 );
			_textFieldA.setTextFieldFilter( new DigitsOnlyFilter() ).setPreferredWidth( 28 );
			_textFieldA.onTextChanged += ( field, str ) =>
			{
				int newA;
				if( int.TryParse( str, out newA ) )
				{
					var newValue = getValue<Color>();
					newValue.A = (byte)newA;
					setValue( newValue );
				}
			};

			var hBox = new HorizontalGroup( 2 );
			hBox.addElement( labelR );
			hBox.addElement( _textFieldR );
			hBox.addElement( labelG );
			hBox.addElement( _textFieldG );
			hBox.addElement( labelB );
			hBox.addElement( _textFieldB );
			hBox.addElement( labelA );
			hBox.addElement( _textFieldA );

			table.add( label );
			table.add( hBox );
		}