Commit 61b63f46 authored by Peining Li's avatar Peining Li
Browse files

Merge branch 'ihm-main/develop' into 'ihm-main/clean_code'

# Conflicts:
#   Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerProfileController.java
parents 05b5d77c e04851bc
......@@ -6,6 +6,7 @@
package com.utclo23.ihmmain.controller;
import com.utclo23.data.structure.PublicUser;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
......@@ -54,7 +55,7 @@ public class PlayerProfileController extends AbstractController{
private boolean isLoading = false;
private boolean isOther = false;
private String attribut;
private String imagePath;
private Image avatarImage;
@FXML
@Override
......@@ -210,7 +211,14 @@ public class PlayerProfileController extends AbstractController{
new Thread(wait).start();
}
}
public void getAvatar(){
byte[] thumbnail = getFacade().iDataIHMMain.getMyPublicUserProfile().getLightPublicUser().getAvatarThumbnail();
//System.out.println(thumbnail);
ByteArrayInputStream inputStream = new ByteArrayInputStream(thumbnail);
avatarImage = new Image(inputStream);
}
@Override
/**
* Initializes all the info of profile.
*/
......@@ -218,8 +226,10 @@ public class PlayerProfileController extends AbstractController{
public void refresh(){
if (!isOther){
try{
//imagePath = me.getLightPublicUser().
image.setImage(new Image (imagePath));
getAvatar();
image.setImage(avatarImage);
me = getFacade().iDataIHMMain.getMyPublicUserProfile();
userID .setText(me.getLightPublicUser().getPlayerName());
firstName.setText(me.getFirstName());
lastName.setText(me.getLastName());
birthday.setText(me.getBirthDate().toString());
......
......@@ -20,6 +20,7 @@ import javafx.scene.control.TextArea;
public class PopupController extends AbstractController{
public String label;
private boolean textnull = true;
@FXML
private TextArea field;
@FXML
......@@ -30,32 +31,39 @@ public class PopupController extends AbstractController{
private void update(ActionEvent event) throws IOException, DataException{
String text;
text = field.getText();
switch(label){
if (text.isEmpty()){
field.setText("Can not send empty string");
}
else{
textnull = false;
switch(label){
case "PlayerName":
//facade.iDataIHMMain.updatePlayername(text);
getFacade().iDataIHMMain.updatePlayername(text);
break;
case "FirstName":
//facade.iDataIHMMain.updateFirstname(text);
getFacade().iDataIHMMain.updateFirstname(text);
break;
case "LastName":
//facade.iDataIHMMain.updateLastname(text);
getFacade().iDataIHMMain.updateLastname(text);
break;
/* To-do: change popup*/
case "Birthday":
//facade.iDataIHMMain.updateLastname(text);
getFacade().iDataIHMMain.updateLastname(text);
break;
case "Password":
//facade.iDataIHMMain.updatePassword(text);
getFacade().iDataIHMMain.updatePassword(text);
break;
default:
Logger.getLogger(
PopupController.class.getName()).log(
Logger.getLogger( PopupController.class.getName()).log(
Level.INFO,
"[PlayerProfile] - error update profile, attribut not found."
);
}
}
if(textnull == false){
getIhmmain().controllerMap.get(SceneName.PLAYER_PROFILE.toString()).refresh();
((Node) (event.getSource())).getScene().getWindow().hide();
}
getIhmmain().controllerMap.get(SceneName.PLAYER_PROFILE.toString()).refresh();
((Node) (event.getSource())).getScene().getWindow().hide();
}
/**
*
......
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