Start working on wallet creation and import screens.

This commit is contained in:
jwinterm
2015-12-15 20:53:06 -08:00
parent 1455636dd4
commit 2803c9a002
7 changed files with 272 additions and 9 deletions
+31 -1
View File
@@ -1,17 +1,47 @@
package com.jw.lightwallet;
import java.io.File;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.jw.lightwallet.screens.CreateScreen;
import com.jw.lightwallet.screens.ImportKeysScreen;
import com.jw.lightwallet.screens.ImportSeedScreen;
import com.jw.lightwallet.screens.MainScreen;
import com.jw.lightwallet.screens.WizardScreen;
public class LightWallet extends Game {
public static final String LOG = LightWallet.class.getSimpleName(); // Logging constant
// Set screen methods
public MainScreen getMainScreen(){
return new MainScreen(this);
}
public WizardScreen getWizardScreen(){
return new WizardScreen(this);
}
public CreateScreen getCreateScreen(){
return new CreateScreen(this);
}
public ImportKeysScreen getImportKeysScreen(){
return new ImportKeysScreen(this);
}
public ImportSeedScreen getImportSeedScreen(){
return new ImportSeedScreen(this);
}
@Override
public void create () {
// Initialize logger
Gdx.app.log(LightWallet.LOG, "Launching application");
setScreen(new MainScreen(this));
// Check if config file exists, if not launch setup wizard
File f = new File("lightwallet.conf");
if(f.exists() && !f.isDirectory()) {
setScreen(getMainScreen());
}
else {setScreen(getWizardScreen());}
}
@@ -14,7 +14,7 @@ public class AbstractScreen implements Screen {
protected float aspect;
protected float accumulator;
public AbstractScreen (LightWallet game) {
public AbstractScreen (final LightWallet game) {
this.game = game;
this.font = new BitmapFont(Gdx.files.internal("fonts/bauchaomaicha.fnt"));
this.w = Gdx.graphics.getWidth();
@@ -26,7 +26,7 @@ public class AbstractScreen implements Screen {
@Override
public void show() {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Showing screen: " + this.getClass().getName());
}
@Override
@@ -39,31 +39,31 @@ public class AbstractScreen implements Screen {
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Resizing screen " + this.getClass().getName() + " to " + width + ", " + height);
}
@Override
public void pause() {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Pausing screen: " + this.getClass().getName());
}
@Override
public void resume() {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Resuming screen: " + this.getClass().getName());
}
@Override
public void hide() {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Hiding screen: " + this.getClass().getName());
}
@Override
public void dispose() {
// TODO Auto-generated method stub
Gdx.app.log(LightWallet.LOG, "Disposing screen: " + this.getClass().getName());
}
}
@@ -0,0 +1,90 @@
package com.jw.lightwallet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.jw.lightwallet.LightWallet;
public class CreateScreen extends AbstractScreen {
Stage stage;
Table screenlayout;
Skin uiSkin;
int padvalue;
Image logo;
Texture logotex;
String instruction;
Label instructionlabel;
Table textcontainer;
Label namelabel;
TextField nametext;
Label pwlabel;
TextField pwtext;
Label pwrptlabel;
TextField pwrpttext;
TextButton createbutton;
TextButton gobackbutton;
public CreateScreen(final LightWallet game) {
super(game);
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
padvalue = 20;
stage = new Stage();
Gdx.input.setInputProcessor(stage);
screenlayout = new Table();
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
instruction = "Please enter a name for your wallet in the \"Wallet name\" field. This is typically wallet.bin, "
+ "but you can make it whatever you like (as long as it is alphanumberic and periods only). "
+ "Then please enter a strong password for your wallet that you will use to unlock, and then repeat it to ensure it is correct. "
+ "Your password can be any combination of characters and symbols on your keyboard (I think).";
instructionlabel= new Label(instruction, uiSkin);
instructionlabel.setWrap(true);
textcontainer = new Table();
textcontainer.add(instructionlabel).width(600);
screenlayout.add(logo).pad(10).center().row();
screenlayout.add(textcontainer).pad(padvalue).row();
//screenlayout.add(buttontable).pad(padvalue).row();
screenlayout.setFillParent(true);
stage.addActor(screenlayout);
}
public void show() {
super.show();
}
public void render(float delta) {
super.render(delta);
stage.draw();
stage.act(delta);
}
public void dispose() {
super.dispose();
}
}
@@ -0,0 +1,12 @@
package com.jw.lightwallet.screens;
import com.jw.lightwallet.LightWallet;
public class ImportKeysScreen extends AbstractScreen {
public ImportKeysScreen(final LightWallet game) {
super(game);
// TODO Auto-generated constructor stub
}
}
@@ -0,0 +1,12 @@
package com.jw.lightwallet.screens;
import com.jw.lightwallet.LightWallet;
public class ImportSeedScreen extends AbstractScreen {
public ImportSeedScreen(final LightWallet game) {
super(game);
// TODO Auto-generated constructor stub
}
}
@@ -41,7 +41,7 @@ public class MainScreen extends AbstractScreen {
// Timer
Timer timer;
public MainScreen(LightWallet game) {
public MainScreen(final LightWallet game) {
super(game);
timer = new Timer();
@@ -132,6 +132,7 @@ public class MainScreen extends AbstractScreen {
}
public void dispose() {
super.dispose();
}
@@ -0,0 +1,118 @@
package com.jw.lightwallet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.jw.lightwallet.LightWallet;
public class WizardScreen extends AbstractScreen {
// Layout stuff
Stage stage;
Table screenlayout;
Skin uiSkin;
int padvalue;
Image logo;
Texture logotex;
Table textcontainer;
Label wizardlabel;
String wizardtext;
Table buttontable;
TextButton createbutton;
TextButton importkeysbutton;
TextButton importseedbutton;
public WizardScreen(final LightWallet game) {
super(game);
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
padvalue = 20;
stage = new Stage();
Gdx.input.setInputProcessor(stage);
screenlayout = new Table();
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
wizardtext = "Hello. It seems this is the either the first time you are launching LightWallet or you have deleted your lightwallet.conf file. "
+ "Please select from the options below whether you would like to create a new wallet, import a wallet from a .keys file, "
+ "or import a wallet using your 25-word mnemonic seed.";
wizardlabel = new Label(wizardtext, uiSkin);
wizardlabel.setWrap(true);
textcontainer = new Table();
textcontainer.add(wizardlabel).width(600);
buttontable = new Table();
createbutton = new TextButton("Create", uiSkin);
createbutton.addListener(new ClickListener() {
@Override
public void clicked (InputEvent event, float x, float y) {
game.setScreen(game.getCreateScreen());
}
});
createbutton.pad(padvalue);
importkeysbutton = new TextButton("Import .keys", uiSkin);
importkeysbutton.addListener(new ClickListener() {
@Override
public void clicked (InputEvent event, float x, float y) {
game.setScreen(game.getImportKeysScreen());
}
});
importkeysbutton.pad(padvalue);
importseedbutton = new TextButton("Import seed", uiSkin);
importseedbutton.addListener(new ClickListener() {
@Override
public void clicked (InputEvent event, float x, float y) {
game.setScreen(game.getImportSeedScreen());
}
});
importseedbutton.pad(padvalue);
buttontable.add(createbutton).width(150);
buttontable.add(importkeysbutton).width(150);
buttontable.add(importseedbutton).width(150);
screenlayout.add(logo).pad(10).center().row();
screenlayout.add(textcontainer).pad(padvalue).row();
screenlayout.add(buttontable).pad(padvalue).row();
screenlayout.setFillParent(true);
stage.addActor(screenlayout);
}
public void show() {
super.show();
}
public void render(float delta) {
super.render(delta);
stage.draw();
stage.act(delta);
}
public void dispose() {
super.dispose();
}
}