Commit f230fe09 authored by Rikysamuel's avatar Rikysamuel
Browse files

comment

parent a4878d14
......@@ -22,6 +22,9 @@ public class InventoryPanel extends javax.swing.JPanel {
initItem();
}
/**
* assign item value from inventory
*/
public void initItem(){
HoneyCount.setText(GrandQuest.inventory.get(0).toString());
HerbsCount.setText(GrandQuest.inventory.get(1).toString());
......
......@@ -44,16 +44,14 @@ public class MapPanel extends javax.swing.JPanel {
static int posX, posY;
static int desiredX, desiredY;
static long moveTime;
static int countStatus;
static int countStatus; // counter for label animation ("Moving....")
static String item;
/**
* Creates new form MapPanel
* @throws java.lang.InterruptedException
*/
public MapPanel() {
System.out.println("sadfka");
countStatus = 0;
posX = Integer.valueOf(Request.findInResponses("x"));
posY = Integer.valueOf(Request.findInResponses("y"));
......@@ -160,6 +158,7 @@ public class MapPanel extends javax.swing.JPanel {
}
}
}
/**
* Map's mouse click listener
*/
......@@ -199,6 +198,13 @@ public class MapPanel extends javax.swing.JPanel {
return new JTable(data, columnNames);
}
/**
* scale a certain image and return it
* @param srcImg
* @param w
* @param h
* @return
*/
private ImageIcon getScaledImage(Image srcImg, int w, int h){
BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = resizedImg.createGraphics();
......@@ -208,6 +214,11 @@ public class MapPanel extends javax.swing.JPanel {
return new ImageIcon(resizedImg);
}
/**
* convert an epoch time format to human DateTime format
* @param time
* @return
*/
public String epochToTime(long time){
Date date = new Date(time);
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
......@@ -216,6 +227,10 @@ public class MapPanel extends javax.swing.JPanel {
return timeStamp;
}
/**
* Timer function to increment time to show current time
* also have a task to apply "move" action
*/
public void incrementTime(){
ActionListener time = new ActionListener() {
......
......@@ -13,7 +13,6 @@ import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
/**
......@@ -38,6 +37,9 @@ public class MixItemPanel extends javax.swing.JPanel {
initItem();
}
/**
* set item value from inventory
*/
public void initItem(){
HoneyCount.setText(GrandQuest.inventory.get(0).toString());
HerbsCount.setText(GrandQuest.inventory.get(1).toString());
......@@ -51,6 +53,13 @@ public class MixItemPanel extends javax.swing.JPanel {
PilospherCount.setText(GrandQuest.inventory.get(9).toString());
}
/**
* scale a certain image and return it
* @param srcImg
* @param w
* @param h
* @return
*/
private ImageIcon getScaledImage(Image srcImg, int w, int h){
BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = resizedImg.createGraphics();
......
......@@ -8,7 +8,6 @@ package GUI;
import Request.Request;
import grandquest.GrandQuest;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
......@@ -21,6 +20,7 @@ public class OfferingPanel extends javax.swing.JPanel {
String firstItem = null;
String secondItem = null;
/**
* Creates new form OfferingPanel
*/
......@@ -30,6 +30,9 @@ public class OfferingPanel extends javax.swing.JPanel {
initItem();
}
/**
* set item value from inventory
*/
public void initItem(){
HoneyCount.setText(GrandQuest.inventory.get(0).toString());
HerbsCount.setText(GrandQuest.inventory.get(1).toString());
......@@ -657,6 +660,7 @@ public class OfferingPanel extends javax.swing.JPanel {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.offer(GrandQuest.token,FirstItem.getName(),FirstAmount.getText(),SecondItem.getName(),SecondAmount.getText()).toString();
System.out.println(sentence);
Request.responseHandler(Request.send(sentence));
}
......
......@@ -11,8 +11,6 @@ import Request.Request;
import grandquest.GrandQuest;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
......@@ -53,10 +51,14 @@ public class TradePanel extends javax.swing.JPanel {
data[i][1] = offers.get(i)[1];
data[i][2] = new ImageIcon(getClass().getResource("/img/herbs.png"));
data[i][3] = offers.get(i)[3];
if (offers.get(i)[4].equals("false")){
data[i][4] = "Fetch";
} else{
data[i][4] = "Cancel";
if (GrandQuest.tableId==0){
if (offers.get(i)[4].equals("false")){
data[i][4] = "Fetch";
} else{
data[i][4] = "Cancel";
}
} else{ // accept panel
}
data[i][5] = offers.get(i)[5];
}
......@@ -69,6 +71,9 @@ public class TradePanel extends javax.swing.JPanel {
return new JTable(data, columnNames);
}
/**
* Offer Table initialization
*/
public void initTable(){
Offer.getColumnModel().getColumn(5).setMinWidth(0);
Offer.getColumnModel().getColumn(5).setMaxWidth(0);
......
......@@ -368,6 +368,7 @@ public class Request {
byte[] resp_byte = new byte[4096];
int resp_size = response.read(resp_byte);
String resp = new String(resp_byte);
System.out.println("resp: " + resp);
return resp;
} catch (IOException ex) {
System.out.println("Disconnected From Server");
......
......@@ -33,6 +33,7 @@ public class GrandQuest {
static public List<Integer> inventory;
static public String offers;
static public int tableId; // table identifier - 0 for tradebox, 1 for accept panel
/**
* used to save a certain panel
......@@ -70,6 +71,7 @@ public class GrandQuest {
}
public void retTrade(){
tableId = 0;
mf.setContentPane(new TradePanel());
mf.revalidate();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment