Commit ae2fa120 authored by opelhoward's avatar opelhoward
Browse files

Merge branch 'master' of...

Merge branch 'master' of http://gitlab.informatika.org/timothy.pratama/IF3230-Tugas-Besar-Sister-2015
parents 58957293 72df4fd6
......@@ -121,13 +121,29 @@ public class Helper {
{
client = new Socket(InetAddress.getByName(server_address), Integer.parseInt(port));
DataOutputStream output = new DataOutputStream(client.getOutputStream());
/* Python Server */
output.write(message.getBytes());
/* Server Java */
// output.writeUTF(message);
InputStream stream = client.getInputStream();
/* Pthyon Server */
byte[] data = new byte[4096];
int count = stream.read(data);
String response = new String(data);
/* Server Java */
// DataInputStream input = new DataInputStream(stream);
// String response = input.readUTF();
/* Python Server */
response = response.substring(0, count);
/* Server Java */
client.close();
return response;
}
......
......@@ -69,7 +69,7 @@
</Component>
<Component class="javax.swing.JTextField" name="server_address_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="167.205.35.100"/>
<Property name="text" type="java.lang.String" value="localhost"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[4, 25]"/>
</Property>
......@@ -82,7 +82,7 @@
</Component>
<Component class="javax.swing.JTextField" name="username_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="dummy"/>
<Property name="text" type="java.lang.String" value="Akatsuki"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[4, 25]"/>
......@@ -145,7 +145,7 @@
</Component>
<Component class="javax.swing.JTextField" name="port_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="8000"/>
<Property name="text" type="java.lang.String" value="8080"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="port_textfieldActionPerformed"/>
......@@ -158,7 +158,7 @@
</Component>
<Component class="javax.swing.JPasswordField" name="password_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="dummy"/>
<Property name="text" type="java.lang.String" value="LogHorizon"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[109, 25]"/>
</Property>
......
......@@ -53,7 +53,7 @@ public class LoginScreen extends javax.swing.JFrame {
server_address_label.setText("Server Address");
getContentPane().add(server_address_label);
server_address_label.setBounds(180, 330, 100, 14);
server_address_label.setBounds(180, 330, 100, 16);
username_label.setText("Username");
getContentPane().add(username_label);
......@@ -61,14 +61,14 @@ public class LoginScreen extends javax.swing.JFrame {
password_label.setText("Password");
getContentPane().add(password_label);
password_label.setBounds(180, 290, 80, 14);
password_label.setBounds(180, 290, 80, 16);
server_address_textfield.setText("167.205.35.100");
server_address_textfield.setText("localhost");
server_address_textfield.setPreferredSize(new java.awt.Dimension(4, 25));
getContentPane().add(server_address_textfield);
server_address_textfield.setBounds(290, 330, 140, 30);
username_textfield.setText("dummy");
username_textfield.setText("Akatsuki");
username_textfield.setToolTipText("");
username_textfield.setPreferredSize(new java.awt.Dimension(4, 25));
getContentPane().add(username_textfield);
......@@ -81,7 +81,7 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(exit_button);
exit_button.setBounds(540, 370, 70, 23);
exit_button.setBounds(540, 370, 70, 26);
login_button.setText("Login");
login_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -90,7 +90,7 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(login_button);
login_button.setBounds(290, 370, 80, 23);
login_button.setBounds(290, 370, 80, 26);
register_button.setText("Register");
register_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -99,13 +99,13 @@ public class LoginScreen extends javax.swing.JFrame {
}
});
getContentPane().add(register_button);
register_button.setBounds(410, 370, 90, 23);
register_button.setBounds(410, 370, 90, 26);
port_label.setText("Port");
getContentPane().add(port_label);
port_label.setBounds(440, 330, 30, 14);
port_label.setBounds(440, 330, 30, 16);
port_textfield.setText("8000");
port_textfield.setText("8080");
port_textfield.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
port_textfieldActionPerformed(evt);
......@@ -114,7 +114,7 @@ public class LoginScreen extends javax.swing.JFrame {
getContentPane().add(port_textfield);
port_textfield.setBounds(470, 330, 140, 30);
password_textfield.setText("dummy");
password_textfield.setText("LogHorizon");
password_textfield.setPreferredSize(new java.awt.Dimension(109, 25));
password_textfield.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
......
......@@ -31,6 +31,13 @@ import javax.swing.JPanel;
*/
public class MainScreen extends javax.swing.JFrame {
private final int max_width = 400;
private final int max_height = 400;
private final int start_x = 100;
private final int start_y = 110;
private int panel_width;
private int panel_height;
/**
* Creates new form MainScreen
*/
......@@ -91,27 +98,27 @@ public class MainScreen extends javax.swing.JFrame {
x_label.setText("x");
getContentPane().add(x_label);
x_label.setBounds(520, 230, 10, 14);
x_label.setBounds(520, 230, 10, 16);
y_label.setText("y");
getContentPane().add(y_label);
y_label.setBounds(520, 260, 10, 14);
y_label.setBounds(520, 260, 10, 16);
position_label.setText("Position");
getContentPane().add(position_label);
position_label.setBounds(520, 140, 60, 14);
position_label.setBounds(520, 140, 60, 16);
current_time_label.setText("Current Time");
getContentPane().add(current_time_label);
current_time_label.setBounds(520, 200, 80, 14);
current_time_label.setBounds(520, 200, 80, 16);
map_label.setText("Map");
getContentPane().add(map_label);
map_label.setBounds(520, 110, 41, 14);
map_label.setBounds(520, 110, 41, 16);
time_label.setText("Time");
getContentPane().add(time_label);
time_label.setBounds(520, 170, 41, 14);
time_label.setBounds(520, 170, 41, 16);
getContentPane().add(position_detail_label);
position_detail_label.setBounds(600, 140, 130, 16);
getContentPane().add(current_time_detail_label);
......@@ -145,7 +152,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(field_button);
field_button.setBounds(570, 300, 100, 23);
field_button.setBounds(570, 300, 100, 26);
inventory_button.setText("Inventory");
inventory_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -154,7 +161,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(inventory_button);
inventory_button.setBounds(570, 340, 100, 23);
inventory_button.setBounds(570, 340, 100, 26);
mix_item_button.setText("Mix Item");
mix_item_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -163,7 +170,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(mix_item_button);
mix_item_button.setBounds(570, 370, 100, 23);
mix_item_button.setBounds(570, 370, 100, 26);
offer_button.setText("Offer");
offer_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -172,7 +179,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(offer_button);
offer_button.setBounds(570, 440, 100, 23);
offer_button.setBounds(570, 440, 100, 26);
logout_button.setText("Logout");
logout_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -181,7 +188,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(logout_button);
logout_button.setBounds(630, 530, 100, 23);
logout_button.setBounds(630, 530, 100, 26);
tradebox_button.setText("Tradebox");
tradebox_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -190,7 +197,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(tradebox_button);
tradebox_button.setBounds(570, 410, 100, 23);
tradebox_button.setBounds(570, 410, 100, 26);
find_item_button.setText("Find Item");
find_item_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -199,7 +206,7 @@ public class MainScreen extends javax.swing.JFrame {
}
});
getContentPane().add(find_item_button);
find_item_button.setBounds(570, 470, 100, 23);
find_item_button.setBounds(570, 470, 100, 26);
background_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/mainscreen_background.jpg"))); // NOI18N
getContentPane().add(background_label);
......@@ -233,13 +240,8 @@ public class MainScreen extends javax.swing.JFrame {
current_time_detail_label.setText(current_date_string);
/* Dynamic Map */
final int max_width = 400;
final int max_height = 400;
final int start_x = 100;
final int start_y = 110;
int panel_width = max_width / map.getWidth();
int panel_height = max_height / map.getHeight();
panel_width = max_width / map.getWidth();
panel_height = max_height / map.getHeight();
java.awt.Color panel_color = new Color(0, 255, 0);
javax.swing.border.Border panel_border = new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true);
JPanel [] panels = new JPanel[map.getWidth() * map.getHeight()];
......@@ -293,6 +295,8 @@ public class MainScreen extends javax.swing.JFrame {
private void move_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_buttonActionPerformed
String x = x_textfield.getText();
String y = y_textfield.getText();
int pos_x = Integer.parseInt(x);
int pos_y = Integer.parseInt(y);
if(x.length() == 0 || y.length() == 0)
{
JOptionPane.showMessageDialog(this, "x and y value are required");
......@@ -306,9 +310,10 @@ public class MainScreen extends javax.swing.JFrame {
Date date = new Date(Long.parseLong(Global.player.getTime()) * 1000);
DateFormat format = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("Asia/Jakarta"));
String date_string = format.format(date);
String date_string = format.format(date);
time_detail_label.setText(date_string);
main_character_label.setBounds(start_x + pos_x * panel_width, start_y + pos_y * panel_height, panel_width, panel_height);
position_detail_label.setText("("+x + "," + y +")");
repaint();
}
else
......
......@@ -5,7 +5,6 @@
*/
package elder.tale;
import java.awt.Color;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
......@@ -17,7 +16,6 @@ import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.border.LineBorder;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
......@@ -27,6 +25,10 @@ import org.json.simple.parser.ParseException;
* @author timothy.pratama
*/
public class TradeboxScreen extends javax.swing.JFrame {
private JLabel [] labels;
private ImageIcon [] icons;
private JButton[] buttons;
/**
* Creates new form TradeboxScreen
......@@ -148,9 +150,9 @@ public class TradeboxScreen extends javax.swing.JFrame {
try
{
JSONArray offers = (JSONArray) parser.parse(Global.SuccessMessage);
JLabel [] labels = new JLabel[offers.size()*4];
ImageIcon [] icons = new ImageIcon[offers.size()*4];
JButton[] buttons = new JButton[offers.size()];
labels = new JLabel[offers.size()*4];
icons = new ImageIcon[offers.size()*4];
buttons = new JButton[offers.size()];
System.out.println("Offers: " + offers.toJSONString());
int j = 0;
int k = 0;
......@@ -201,19 +203,23 @@ public class TradeboxScreen extends javax.swing.JFrame {
canvas_main_panel.add(buttons[k]);
if(temp.get(4).toString().equals("false"))
{
int index1 = j;
int index2 = k;
buttons[k].setText("Fetch");
buttons[k].addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Fetch(evt, temp.get(5).toString());
Fetch(evt, temp.get(5).toString(), index1, index2);
}
});
}
else
{
int index1 = j;
int index2 = k;
buttons[k].setText("Cancel");
buttons[k].addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Cancel(evt, temp.get(5).toString());
Cancel(evt, temp.get(5).toString(), index1, index2);
}
});
}
......@@ -234,11 +240,17 @@ public class TradeboxScreen extends javax.swing.JFrame {
}
}//GEN-LAST:event_formWindowOpened
private void Fetch(java.awt.event.ActionEvent evt, String other_token) {
private void Fetch(java.awt.event.ActionEvent evt, String other_token, int index1, int index2) {
boolean success = Helper.Fetch(other_token);
if(success)
{
JOptionPane.showMessageDialog(this, Global.SuccessMessage);
canvas_main_panel.remove(labels[index1-1]);
canvas_main_panel.remove(labels[index1-2]);
canvas_main_panel.remove(labels[index1-3]);
canvas_main_panel.remove(labels[index1-4]);
canvas_main_panel.remove(buttons[index2]);
repaint();
}
else
{
......@@ -246,11 +258,17 @@ public class TradeboxScreen extends javax.swing.JFrame {
}
}
private void Cancel(java.awt.event.ActionEvent evt, String other_token) {
private void Cancel(java.awt.event.ActionEvent evt, String other_token, int index1, int index2) {
boolean success = Helper.Cancel(other_token);
if(success)
{
JOptionPane.showMessageDialog(this, Global.SuccessMessage);
canvas_main_panel.remove(labels[index1-1]);
canvas_main_panel.remove(labels[index1-2]);
canvas_main_panel.remove(labels[index1-3]);
canvas_main_panel.remove(labels[index1-4]);
canvas_main_panel.remove(buttons[index2]);
repaint();
}
else
{
......
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