mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-12-02 11:53:56 +01:00
Worked on layout for daemon a bit.
This commit is contained in:
@@ -9,8 +9,8 @@ import com.jw.lightwallet.LightWallet;
|
||||
public class AbstractScreen implements Screen {
|
||||
protected LightWallet game;
|
||||
protected BitmapFont font;
|
||||
protected float w;
|
||||
protected float h;
|
||||
protected int w;
|
||||
protected int h;
|
||||
protected float aspect;
|
||||
protected float accumulator;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AbstractScreen implements Screen {
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(1, 0, 0, 1);
|
||||
Gdx.gl.glClearColor(0, 0, 0, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
accumulator = accumulator + delta;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
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.jw.lightwallet.utils.Constants;
|
||||
import com.jw.lightwallet.utils.DaemonValues;
|
||||
|
||||
public class DaemonView {
|
||||
|
||||
Table daemonlayout;
|
||||
|
||||
Label nodelabel;
|
||||
Label nodevalue;
|
||||
Label statuslabel;
|
||||
Label statusvalue;
|
||||
Label heightlabel;
|
||||
Label heightvalue;
|
||||
Label hashratelabel;
|
||||
Label hashratevalue;
|
||||
Label rewardlabel;
|
||||
Label rewardvalue;
|
||||
|
||||
|
||||
public DaemonView () {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
daemonlayout = new Table();
|
||||
|
||||
|
||||
|
||||
nodelabel = new Label("Node address: ", uiSkin);
|
||||
nodevalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(nodelabel).pad(20);
|
||||
daemonlayout.add(nodevalue).pad(20).row();
|
||||
|
||||
statuslabel = new Label("Node status: ", uiSkin);
|
||||
statusvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(statuslabel).pad(20);
|
||||
daemonlayout.add(statusvalue).pad(20).row();
|
||||
|
||||
heightlabel = new Label("Block height: ", uiSkin);
|
||||
heightvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(heightlabel).pad(20);
|
||||
daemonlayout.add(heightvalue).pad(20).row();
|
||||
|
||||
hashratelabel = new Label("Network hashrate: ", uiSkin);
|
||||
hashratevalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(hashratelabel).pad(20);
|
||||
daemonlayout.add(hashratevalue).pad(20).row();
|
||||
|
||||
rewardlabel = new Label("Last reward: ", uiSkin);
|
||||
rewardvalue = new Label(null, uiSkin);
|
||||
daemonlayout.add(rewardlabel).pad(20);
|
||||
daemonlayout.add(rewardvalue).pad(20).row();
|
||||
}
|
||||
|
||||
public void Update(DaemonValues daemonvalues) {
|
||||
nodevalue.setText(Constants.moneroclub);
|
||||
statusvalue.setText(daemonvalues.getStatus());
|
||||
heightvalue.setText(String.valueOf(daemonvalues.getBlockheight()));
|
||||
hashratevalue.setText(String.valueOf(daemonvalues.getHashrate()));
|
||||
rewardvalue.setText(String.valueOf(daemonvalues.getLastblockreward()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
public class HistoryView {
|
||||
|
||||
}
|
||||
@@ -1,37 +1,38 @@
|
||||
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.Container;
|
||||
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.utils.Timer;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
import com.jw.lightwallet.daemon.DaemonRPC;
|
||||
import com.jw.lightwallet.utils.Constants;
|
||||
import com.jw.lightwallet.utils.DaemonValues;
|
||||
|
||||
|
||||
public class MainScreen extends AbstractScreen {
|
||||
// Interface classes
|
||||
DaemonRPC daemonrpc;
|
||||
DaemonValues daemonvalues;
|
||||
DaemonRPC daemonrpc;
|
||||
DaemonValues daemonvalues;
|
||||
// Layout stuff
|
||||
Table screenlayout;
|
||||
TextButton daemonbutton;
|
||||
TextButton walletbutton;
|
||||
// Daemon layout
|
||||
Table daemonlayout;
|
||||
Image logo;
|
||||
Label statuslabel;
|
||||
Label statusvalue;
|
||||
Label blockheightlabel;
|
||||
Label blockheightvalue;
|
||||
Label difflabel;
|
||||
Label diffvalue;
|
||||
Label hashratelabel;
|
||||
Label hashratevalue;
|
||||
Label lastblocktimelabel;
|
||||
Label lastblocktimevalue;
|
||||
Label rewardlabel;
|
||||
Label rewardvalue;
|
||||
Stage stage;
|
||||
Table screenlayout;
|
||||
|
||||
Image logo;
|
||||
Texture logotex;
|
||||
Table buttonrow;
|
||||
TextButton daemonbutton;
|
||||
TextButton walletbutton;
|
||||
TextButton transferbutton;
|
||||
TextButton txhistorybutton;
|
||||
Table viewcontainer;
|
||||
DaemonView daemonview;
|
||||
|
||||
// Wallet layout
|
||||
// Transfer layout
|
||||
// Tx history layout
|
||||
@@ -40,11 +41,41 @@ public class MainScreen extends AbstractScreen {
|
||||
|
||||
public MainScreen(LightWallet game) {
|
||||
super(game);
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
daemonrpc = new DaemonRPC();
|
||||
daemonvalues = new DaemonValues();
|
||||
daemonrpc.getinfo(daemonvalues);
|
||||
|
||||
stage = new Stage();
|
||||
|
||||
screenlayout = new Table();
|
||||
viewcontainer = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
|
||||
buttonrow = new Table();
|
||||
daemonbutton = new TextButton("Daemon", uiSkin);
|
||||
walletbutton = new TextButton("Wallet", uiSkin);
|
||||
transferbutton = new TextButton("Transfer", uiSkin);
|
||||
txhistorybutton = new TextButton("History", uiSkin);
|
||||
|
||||
buttonrow.add(daemonbutton).width(Constants.WORLD_WIDTH/4);
|
||||
buttonrow.add(walletbutton).width(Constants.WORLD_WIDTH/4);
|
||||
buttonrow.add(transferbutton).width(Constants.WORLD_WIDTH/4);
|
||||
buttonrow.add(txhistorybutton).width(Constants.WORLD_WIDTH/4);
|
||||
screenlayout.add(buttonrow).row();
|
||||
|
||||
screenlayout.add(logo).center().row();
|
||||
|
||||
daemonview = new DaemonView();
|
||||
viewcontainer.add(daemonview.daemonlayout).expand().bottom();
|
||||
screenlayout.add(viewcontainer);
|
||||
|
||||
screenlayout.setFillParent(true);
|
||||
stage.addActor(screenlayout);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
@@ -53,14 +84,18 @@ public class MainScreen extends AbstractScreen {
|
||||
timer.scheduleTask(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.print(daemonvalues.getBlockheight());
|
||||
daemonrpc.getinfo(daemonvalues);
|
||||
daemonview.Update(daemonvalues);
|
||||
}
|
||||
}, 5f, 5f);
|
||||
}, 1f, 5f);
|
||||
|
||||
}
|
||||
|
||||
public void render(float delta) {
|
||||
super.render(delta);
|
||||
|
||||
stage.draw();
|
||||
stage.act(delta);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
public class TransactionView {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
public class WalletView {
|
||||
|
||||
}
|
||||
@@ -3,5 +3,10 @@ package com.jw.lightwallet.utils;
|
||||
public class Constants {
|
||||
public static final int DESKTOP_WIDTH = 800;
|
||||
public static final int DESKTOP_HEIGHT = 600;
|
||||
|
||||
public static final float WORLD_WIDTH = 800;
|
||||
public static final float WORLD_HEIGHT = 600;
|
||||
|
||||
public static final String moneroclub = "http://node.monoerclub.com/json_rpc:8880";
|
||||
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class DaemonValues {
|
||||
this.lastblocktime = lastblocktime;
|
||||
}
|
||||
|
||||
public int getLastblockreward() {
|
||||
return lastblockreward;
|
||||
public float getLastblockreward() {
|
||||
return lastblockreward/1e12f;
|
||||
}
|
||||
public void setLastblockreward(int lastblockreward) {
|
||||
this.lastblockreward = lastblockreward;
|
||||
|
||||
Reference in New Issue
Block a user