Commit 9496ebe1 authored by Timothy Pratama's avatar Timothy Pratama
Browse files

(client) Main Screen current time -> real time update.

(client) Check validation if player move is out of bound.
parent b4a2507a
......@@ -69,7 +69,7 @@
</Component>
<Component class="javax.swing.JTextField" name="server_address_textfield">
<Properties>
<Property name="text" type="java.lang.String" value="localhost"/>
<Property name="text" type="java.lang.String" value="167.205.35.173"/>
<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="Akatsuki"/>
<Property name="text" type="java.lang.String" value="timmy"/>
<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="8080"/>
<Property name="text" type="java.lang.String" value="8000"/>
</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="LogHorizon"/>
<Property name="text" type="java.lang.String" value="timmy"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[109, 25]"/>
</Property>
......
......@@ -63,12 +63,12 @@ public class LoginScreen extends javax.swing.JFrame {
getContentPane().add(password_label);
password_label.setBounds(180, 290, 80, 16);
server_address_textfield.setText("localhost");
server_address_textfield.setText("167.205.35.173");
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("Akatsuki");
username_textfield.setText("timmy");
username_textfield.setToolTipText("");
username_textfield.setPreferredSize(new java.awt.Dimension(4, 25));
getContentPane().add(username_textfield);
......@@ -105,7 +105,7 @@ public class LoginScreen extends javax.swing.JFrame {
getContentPane().add(port_label);
port_label.setBounds(440, 330, 30, 16);
port_textfield.setText("8080");
port_textfield.setText("8000");
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("LogHorizon");
password_textfield.setText("timmy");
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) {
......
......@@ -45,6 +45,43 @@ public class MainScreen extends javax.swing.JFrame {
initComponents();
}
private Map map;
private class TimeUpdater implements Runnable
{
private Thread t;
public TimeUpdater() {
}
@Override
public void run() {
while(true)
{
try {
DateFormat format = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("Asia/Jakarta"));
Date current_date = new Date(System.currentTimeMillis());
String current_date_string = format.format(current_date);
current_time_detail_label.setText(current_date_string);
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void start()
{
if(t==null)
{
t = new Thread(this);
t.start();
}
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
......@@ -218,7 +255,7 @@ public class MainScreen extends javax.swing.JFrame {
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
Map map = Helper.GetMap();
map = Helper.GetMap();
if(map != null)
{
map_detail_label.setText(map.getName());
......@@ -232,12 +269,11 @@ public class MainScreen extends javax.swing.JFrame {
format.setTimeZone(TimeZone.getTimeZone("Asia/Jakarta"));
String date_string = format.format(date);
Date current_date = new Date(System.currentTimeMillis());
String current_date_string = format.format(current_date);
position_detail_label.setText("("+pos_x + "," + pos_y +")");
time_detail_label.setText(date_string);
current_time_detail_label.setText(current_date_string);
TimeUpdater timeUpdater = new TimeUpdater();
timeUpdater.start();
/* Dynamic Map */
panel_width = max_width / map.getWidth();
......@@ -301,7 +337,11 @@ public class MainScreen extends javax.swing.JFrame {
{
JOptionPane.showMessageDialog(this, "x and y value are required");
}
else
else if(pos_x >= map.getWidth() || pos_y >= map.getHeight())
{
JOptionPane.showMessageDialog(this, "x or y value are out of bound");
}
else
{
Boolean success = Helper.Move(x, y);
if(success)
......
......@@ -207,6 +207,24 @@ public class MixItemScreen extends javax.swing.JFrame {
if(sukses)
{
JOptionPane.showMessageDialog(this, Global.SuccessMessage);
boolean berhasil = Helper.Inventory();
if(berhasil)
{
honey_label.setText(String.valueOf(Global.player.inventory[0]));
herbs_label.setText(String.valueOf(Global.player.inventory[1]));
clay_label.setText(String.valueOf(Global.player.inventory[2]));
mineral_label.setText(String.valueOf(Global.player.inventory[3]));
potion_label.setText(String.valueOf(Global.player.inventory[4]));
incense_label.setText(String.valueOf(Global.player.inventory[5]));
gems_label.setText(String.valueOf(Global.player.inventory[6]));
life_elixir_label.setText(String.valueOf(Global.player.inventory[7]));
mana_crystal_label.setText(String.valueOf(Global.player.inventory[8]));
philosopher_stone_label.setText(String.valueOf(Global.player.inventory[9]));
}
else
{
JOptionPane.showMessageDialog(this, Global.ErrorMessage);
}
}
else
{
......
......@@ -161,11 +161,12 @@
</Component>
<Component class="javax.swing.JLabel" name="item1_label">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="item"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="130" y="400" width="-1" height="-1"/>
<AbsoluteConstraints x="105" y="400" width="50" height="-1"/>
</Constraint>
</Constraints>
</Component>
......@@ -209,11 +210,12 @@
</Component>
<Component class="javax.swing.JLabel" name="item2_label">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Item"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="470" y="400" width="-1" height="-1"/>
<AbsoluteConstraints x="435" y="400" width="60" height="-1"/>
</Constraint>
</Constraints>
</Component>
......
......@@ -119,9 +119,10 @@ public class OfferItemScreen extends javax.swing.JFrame {
getContentPane().add(offer_item_label);
offer_item_label.setBounds(110, 350, 210, 30);
item1_label.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
item1_label.setText("item");
getContentPane().add(item1_label);
item1_label.setBounds(130, 400, 20, 14);
item1_label.setBounds(105, 400, 50, 16);
item1_combobox.setMaximumRowCount(5);
item1_combobox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--- Select an Item ---", "Honey", "Herbs", "Clay", "Mineral", "Potion", "Incense", "Gems", "Life Elixir", "Mana Crystal", "Philosopher Stone" }));
......@@ -131,15 +132,16 @@ public class OfferItemScreen extends javax.swing.JFrame {
}
});
getContentPane().add(item1_combobox);
item1_combobox.setBounds(170, 400, 150, 20);
item1_combobox.setBounds(170, 400, 150, 25);
n1_label.setText("Quantity");
getContentPane().add(n1_label);
n1_label.setBounds(110, 440, 70, 14);
n1_label.setBounds(110, 440, 70, 16);
item2_label.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
item2_label.setText("Item");
getContentPane().add(item2_label);
item2_label.setBounds(470, 400, 22, 14);
item2_label.setBounds(435, 400, 60, 16);
item2_combobox.setMaximumRowCount(5);
item2_combobox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--- Select an Item ---", "Honey", "Herbs", "Clay", "Mineral", "Potion", "Incense", "Gems", "Life Elixir", "Mana Crystal", "Philosopher Stone" }));
......@@ -149,11 +151,11 @@ public class OfferItemScreen extends javax.swing.JFrame {
}
});
getContentPane().add(item2_combobox);
item2_combobox.setBounds(510, 400, 150, 20);
item2_combobox.setBounds(510, 400, 150, 25);
n2_label.setText("Quantity");
getContentPane().add(n2_label);
n2_label.setBounds(450, 440, 60, 14);
n2_label.setBounds(450, 440, 60, 16);
save_button.setText("Save");
save_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -162,7 +164,7 @@ public class OfferItemScreen extends javax.swing.JFrame {
}
});
getContentPane().add(save_button);
save_button.setBounds(590, 480, 70, 23);
save_button.setBounds(590, 480, 70, 26);
back_button.setText("Back");
back_button.addActionListener(new java.awt.event.ActionListener() {
......@@ -171,7 +173,7 @@ public class OfferItemScreen extends javax.swing.JFrame {
}
});
getContentPane().add(back_button);
back_button.setBounds(660, 40, 81, 23);
back_button.setBounds(660, 40, 81, 26);
getContentPane().add(n1_textfield);
n1_textfield.setBounds(170, 440, 150, 30);
getContentPane().add(n2_textfield);
......
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