aboutsummaryrefslogtreecommitdiff
path: root/client/shaders/wielded_shader/opengl_fragment.glsl
Commit message (Expand)AuthorAge
* Shaders: Remove unnecessary 'if' statementsLars Hofhansl2016-12-24
* Fog: Make fraction of visible distance at which fog starts configurableLars Hofhansl2016-12-07
* Fix unexplained shader issue (glsl compiler bug??) (#4757)Rogier-52016-11-17
* Shaders: Harmonize Irrlicht and shader fog calculationsLars Hofhansl2016-10-24
* Use range-based fog instead of z-plane based.Lars Hofhansl2016-10-13
* Add wielded (and CAOs) shaderRealBadAngel2015-07-21
ref='#n52'>52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
package net.minetest.minetest;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;

public class MinetestTextEntry extends Activity {
	public AlertDialog mTextInputDialog;
	public EditText mTextInputWidget;
	
	private final int MultiLineTextInput              = 1;
	private final int SingleLineTextInput             = 2;
	private final int SingleLinePasswordInput         = 3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Bundle b = getIntent().getExtras();
		String acceptButton = b.getString("EnterButton");
		String hint         = b.getString("hint");
		String current      = b.getString("current");
		int    editType     = b.getInt("editType");
		
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		mTextInputWidget = new EditText(this);
		mTextInputWidget.setHint(hint);
		mTextInputWidget.setText(current);
		mTextInputWidget.setMinWidth(300);
		if (editType == SingleLinePasswordInput) {
			mTextInputWidget.setInputType(InputType.TYPE_CLASS_TEXT | 
					InputType.TYPE_TEXT_VARIATION_PASSWORD);
		}
		else {
			mTextInputWidget.setInputType(InputType.TYPE_CLASS_TEXT);
		}
		
		
		builder.setView(mTextInputWidget);
		
		if (editType == MultiLineTextInput) {
			builder.setPositiveButton(acceptButton, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int whichButton) 
				{ pushResult(mTextInputWidget.getText().toString()); }
				});
		}
		
		builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
			public void onCancel(DialogInterface dialog) {
				cancelDialog();
			}
		});
		
		mTextInputWidget.setOnKeyListener(new OnKeyListener() {
			@Override
			public boolean onKey(View view, int KeyCode, KeyEvent event) {
				if ( KeyCode == KeyEvent.KEYCODE_ENTER){

					pushResult(mTextInputWidget.getText().toString());
					return true;
				}
				return false;
			}
		});
		
		mTextInputDialog = builder.create();
		mTextInputDialog.show();
	}
	
	public void pushResult(String text) {
		Intent resultData = new Intent();
		resultData.putExtra("text", text);
		setResult(Activity.RESULT_OK,resultData);
		mTextInputDialog.dismiss();
		finish();
	}
	
	public void cancelDialog() {
		setResult(Activity.RESULT_CANCELED);
		mTextInputDialog.dismiss();
		finish();
	}
}