Commit cce40948 authored by Frantisek Simon's avatar Frantisek Simon

#78 Split user model to shared model, DAO and menu item

parent a7c38141
[submodule "core/src/cz/nic/tablexia/shared"]
path = core/src/cz/nic/tablexia/shared
url = git@gitlab.labs.nic.cz:mlatner/Tablexia-Model.git
......@@ -11,7 +11,8 @@ import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
import cz.nic.tablexia.screen.loader.LoaderScreen;
......@@ -163,7 +164,7 @@ public class TablexiaSettings {
public void loadPreferences(boolean reset) {
preferences = Gdx.app.getPreferences(PREFERENCES_KEY + BUILD_TYPE.getKey());
selectedLocale = LocaleDefinition.getLocaleDefinitionForKey(preferences.getString(LOCALE_KEY));
selectedUser = reset ? null : User.selectUser(preferences.getLong(SELECTED_USER));
selectedUser = reset ? null : UserDAO.selectUser(preferences.getLong(SELECTED_USER));
}
......
......@@ -17,9 +17,10 @@ import java.util.Map;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.TablexiaAbstractFileManager;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.model.game.Game;
import cz.nic.tablexia.model.game.GamePause;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.model.game.GameScore;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.Log;
......@@ -121,7 +122,7 @@ public class TablexiaStorage {
private void initTables() {
try {
Statement statement = createStatement();
statement.execute(User.CREATE_TABLE);
statement.execute(UserDAO.CREATE_TABLE);
statement.execute(Game.CREATE_TABLE);
statement.execute(GameScore.CREATE_TABLE);
statement.execute(GamePause.CREATE_TABLE);
......@@ -134,7 +135,7 @@ public class TablexiaStorage {
}
private void MigrateData() {
User.migrateUserSignaturesData();
UserDAO.migrateUserSignaturesData();
}
private void reset(boolean reset) {
......
......@@ -22,7 +22,7 @@ import cz.nic.tablexia.TablexiaApplication.ScreenChangedEvent;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.AbstractTablexiaScreen.ScreenInfoEvent;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.alpha;
......
......@@ -41,6 +41,7 @@ import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.main.MainMenu;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.model.game.Game;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
......@@ -280,7 +281,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
// create new
TablexiaRandom random = TablexiaSettings.GAMES_RANDOM_SEED == null ? new TablexiaRandom() : new TablexiaRandom(TablexiaSettings.GAMES_RANDOM_SEED);
GameDefinition gameDefinition = GameDefinition.getGameDefinitionForClass(AbstractTablexiaGame.this.getClass());
GameDifficulty gameDifficulty = gameDefinition.hasTutorial() && getSelectedUser().isTutorialForGameDefinition(gameDefinition) ? GameDifficulty.TUTORIAL : TablexiaSettings.getInstance().getGameDifficulty(gameDefinition);
GameDifficulty gameDifficulty = gameDefinition.hasTutorial() && UserDAO.isTutorialForGameDefinition(gameDefinition, getSelectedUser()) ? GameDifficulty.TUTORIAL : TablexiaSettings.getInstance().getGameDifficulty(gameDefinition);
game = Game.createGame(getSelectedUser(), gameDifficulty, gameDefinition, random);
Log.info(getClass(), "[DB] Created new GAME object: " + game);
} else {
......
......@@ -19,7 +19,7 @@ import cz.nic.tablexia.game.games.robbery.creature.CreatureFactory;
import cz.nic.tablexia.game.games.robbery.rules.GameRule;
import cz.nic.tablexia.game.games.robbery.rules.GameRulesDefinition;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.model.game.Game;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.ScaleUtil;
......
......@@ -21,7 +21,7 @@ package cz.nic.tablexia.game.trophy;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.model.game.GameTrophy;
/**
......
......@@ -18,18 +18,13 @@
******************************************************************************/
package cz.nic.tablexia.game.trophy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
public interface ITrophyDefinition {
public String getTrophyName();
public String getTrophyDescription();
public boolean hasTrophy(User user);
public String name();
String getTrophyName();
String getTrophyDescription();
boolean hasTrophy(User user);
String name();
}
......@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.model.game.*;
/**
......
......@@ -16,9 +16,11 @@ import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.menu.user.UserMenuItem;
import cz.nic.tablexia.menu.user.UserMenuNewSelectBoxItemGroup;
import cz.nic.tablexia.menu.user.UserMenuSelectBoxItemGroup;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.createuser.PanoramaScreen;
import cz.nic.tablexia.util.ui.AbstractTablexiaSelectBox;
......@@ -70,8 +72,8 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS
removeCaptureListener(changeListener);
UserMenuSelectBoxItemGroup selectedUserItem = null;
List<UserSelectBoxItem> userItems = new ArrayList<UserSelectBoxItem>();
for (User user: User.selectActiveUsers()) {
UserMenuSelectBoxItemGroup userItem = new UserMenuSelectBoxItemGroup(user, getWidth());
for (User user: UserDAO.selectActiveUsers()) {
UserMenuSelectBoxItemGroup userItem = new UserMenuSelectBoxItemGroup(new UserMenuItem(user), getWidth());
userItems.add(userItem);
if (user.equals(TablexiaSettings.getInstance().getSelectedUser())) {
selectedUserItem = userItem;
......
......@@ -15,8 +15,8 @@ import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.event.MenuControlEvent;
import cz.nic.tablexia.loader.application.ApplicationSoundManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.IMenuItem;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.createuser.PanoramaScreen;
/**
......@@ -54,7 +54,8 @@ public class UserMenu extends AbstractMenu {
container.setFillParent(true);
final float userMenuItemWidth = getBackground().getWidth();
for (final IMenuItem menuItem : User.selectActiveUsers()) {
for (final User user : UserDAO.selectActiveUsers()) {
final UserMenuItem menuItem = new UserMenuItem(user);
Group userItemGroup = getGroupForMenuItem(menuItem, getWidth());
userItemGroup.setSize(userMenuItemWidth, USER_ITEM_HEIGHT);
userItemGroup.addListener(new ClickListener() {
......@@ -96,7 +97,7 @@ public class UserMenu extends AbstractMenu {
//////////////////////////// CREATE USER EVENT HANDLING
@Handler
public void handleCreatedUserEvent(User.CreatedUserEvent createdUserEvent) {
public void handleCreatedUserEvent(UserDAO.CreatedUserEvent createdUserEvent) {
initMenuItems();
}
}
package cz.nic.tablexia.menu.user;
import com.badlogic.gdx.scenes.scene2d.Group;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.IMenuItem;
import cz.nic.tablexia.shared.model.User;
/**
* Created by frantisek on 11.1.16.
*/
public class UserMenuItem implements IMenuItem {
private User user;
private static final Class<UserMenuSelectBoxItemGroup> USER_ITEM_CLASS = UserMenuSelectBoxItemGroup.class;
public UserMenuItem(User user) {
this.user = user;
}
@Override
public String getTitle() {
return user.getName();
}
@Override
public String getDescription() {
return null;
}
@Override
public String[] getIcons() {
// TODO return user avatar
return null;
}
@Override
public Class<? extends Group> getItemGroupClass() {
return USER_ITEM_CLASS;
}
@Override
public void performAction() {
TablexiaSettings.getInstance().setSelectedUser(this.user);
}
@Override
public AbstractMenu.MenuAction getMenuAction() {
return AbstractMenu.MenuAction.HIDE;
}
@Override
public IMenuItem[] getSubmenu() {
return null;
}
}
......@@ -11,7 +11,6 @@ import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.menu.IMenuItem;
import cz.nic.tablexia.menu.main.user.UserSelectBox;
import cz.nic.tablexia.model.User;
/**
* Created by Matyáš Latner.
......@@ -26,10 +25,10 @@ public class UserMenuSelectBoxItemGroup extends Group implements UserSelectBox.U
private final NinePatch background;
private final BitmapFont font;
private final TextureRegionDrawable image;
private final User user;
private final UserMenuItem userMenuItem;
public UserMenuSelectBoxItemGroup(IMenuItem menuItem, float width) {
this.user = (User) menuItem;
this.userMenuItem = (UserMenuItem)menuItem;
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUITEM_BACKGROUND);
font = ApplicationFontManager.getInstance().getFont(TEXT_FONT);
......@@ -37,7 +36,7 @@ public class UserMenuSelectBoxItemGroup extends Group implements UserSelectBox.U
}
public void performAction() {
user.performAction();
userMenuItem.performAction();
}
@Override
......@@ -52,6 +51,6 @@ public class UserMenuSelectBoxItemGroup extends Group implements UserSelectBox.U
float textPositionX = getX() + imageWidth + TEXT_LEFT_OFFSET;
float textPositionY = getY() + getHeight() / 2;
font.draw(batch, user.getName(), textPositionX, textPositionY + font.getLineHeight() / 3);
font.draw(batch, userMenuItem.getTitle(), textPositionX, textPositionY + font.getLineHeight() / 3);
}
}
package cz.nic.tablexia.model;
import com.badlogic.gdx.scenes.scene2d.Group;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
......@@ -10,170 +8,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.TablexiaStorage;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.IMenuItem;
import cz.nic.tablexia.menu.user.UserMenuSelectBoxItemGroup;
import cz.nic.tablexia.model.game.Game;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
* Created by lhoracek, Matyáš Latner
*/
public class User implements IMenuItem {
private static final Class<UserMenuSelectBoxItemGroup> USER_ITEM_CLASS = UserMenuSelectBoxItemGroup.class;
public enum Gender {
FEMALE(0),
MALE(1);
private int genderId;
Gender(int genderId) {
this.genderId = genderId;
}
public static Gender getGenderForId(int genderId) {
for (Gender gender : Gender.values()) {
if (gender.genderId == genderId) {
return gender;
}
}
return null;
}
}
private final Long id;
private final String name;
private final String avatar;
private final String signature;
private final int age;
private final Gender gender;
private boolean deleted;
private boolean help;
private boolean intro;
//need to be pulic for testing purposes
public User(long id, String name, int age, Gender gender, String avatar, String signature, boolean deleted, boolean help, boolean intro) {
this.id = id;
this.name = name;
this.age = age;
this.gender = gender;
this.signature = signature;
this.avatar = avatar;
this.deleted = deleted;
this.help = help;
this.intro = intro;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public Gender getGender() {
return gender;
}
public boolean isDeleted() {
return deleted;
}
public boolean isHelp() {
return help;
}
public boolean isIntro() {
return intro;
}
public String getAvatar() {
return avatar;
}
public String getSignature() {
return signature;
}
public void setIntro(boolean intro) {
this.intro = intro;
}
public void setHelp(boolean help) {
this.help = help;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof User)) {
return false;
}
return ((User) obj).getId().equals(getId());
}
@Override
public String toString() {
return "USER[id: " + id + ", name: " + name + ", age: " + age + ", gen: " + gender.name() + ", del: " + deleted + ", help: " + help + ", intro: " + intro + "]";
}
//////////////////////////// USER MENU ITEM
@Override
public String getTitle() {
return getName();
}
@Override
public String getDescription() {
return null;
}
@Override
public String[] getIcons() {
// TODO return user avatar
return null;
}
@Override
public Class<? extends Group> getItemGroupClass() {
return USER_ITEM_CLASS;
}
@Override
public void performAction() {
TablexiaSettings.getInstance().setSelectedUser(this);
}
@Override
public AbstractMenu.MenuAction getMenuAction() {
return AbstractMenu.MenuAction.HIDE;
}
@Override
public IMenuItem[] getSubmenu() {
return null;
}
public class UserDAO {
//////////////////////////// DB ACCESS
......@@ -195,7 +41,7 @@ public class User implements IMenuItem {
long id = resultSet.getLong(1);
String name = resultSet.getString(2);
int age = resultSet.getInt(3);
Gender gender = Gender.getGenderForId(resultSet.getInt(4));
User.Gender gender = User.Gender.getGenderForId(resultSet.getInt(4));
String avatar = resultSet.getString(5);
String signature = resultSet.getString(6);
boolean deleted = resultSet.getInt(7) != 0;
......@@ -214,13 +60,13 @@ public class User implements IMenuItem {
return users;
}
public static User createUser(String name, int age, Gender gender, String avatar, String signature) {
public static User createUser(String name, int age, User.Gender gender, String avatar, String signature) {
User user = null;
try {
PreparedStatement insertStatement = TablexiaStorage.getInstance().prepareStatement(INSERT_USER);
insertStatement.setString(1, name);
insertStatement.setInt(2, age);
insertStatement.setInt(3, gender.genderId);
insertStatement.setInt(3, gender.getGenderId());
insertStatement.setString(4, avatar);
insertStatement.setString(5, signature);
insertStatement.executeUpdate();
......@@ -262,7 +108,7 @@ public class User implements IMenuItem {
if (resultSet.next()) {
String name = resultSet.getString(2);
int age = resultSet.getInt(3);
Gender gender = Gender.getGenderForId(resultSet.getInt(4));
User.Gender gender = User.Gender.getGenderForId(resultSet.getInt(4));
String avatar = resultSet.getString(5);
String signature = resultSet.getString(6);
boolean deleted = resultSet.getInt(7) != 0;
......@@ -292,7 +138,7 @@ public class User implements IMenuItem {
Long id = resultSet.getLong(1);
String name = resultSet.getString(2);
int age = resultSet.getInt(3);
Gender gender = Gender.getGenderForId(resultSet.getInt(4));
User.Gender gender = User.Gender.getGenderForId(resultSet.getInt(4));
String avatar = resultSet.getString(5);
String signature = resultSet.getString(6);
boolean deleted = resultSet.getInt(7) != 0;
......@@ -312,8 +158,8 @@ public class User implements IMenuItem {
return selectedUser;
}
public boolean isTutorialForGameDefinition(GameDefinition gameDefinition) {
return Game.getNumberOfCompleteGamesForGameDefinitionAndDifficulty(gameDefinition, GameDifficulty.TUTORIAL, this) < 1;
public static boolean isTutorialForGameDefinition(GameDefinition gameDefinition, User user) {
return Game.getNumberOfCompleteGamesForGameDefinitionAndDifficulty(gameDefinition, GameDifficulty.TUTORIAL, user) < 1;
}
public static boolean userNameExists(String name) {
......
......@@ -17,7 +17,8 @@ import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
......@@ -244,7 +245,7 @@ public class Game {
String startTimeStr = resultSet.getString(6);
String endTimeStr = resultSet.getString(7);
selectedGame = new Game(resultSet.getLong(1),
User.selectUser(resultSet.getLong(2)),
UserDAO.selectUser(resultSet.getLong(2)),
GameDifficulty.getGameDifficultyForDifficultyNumber(resultSet.getInt(3)),
GameDefinition.getGameDefinitionForGameNumber(resultSet.getInt(4)),
new TablexiaRandom(resultSet.getLong(5)),
......@@ -283,7 +284,7 @@ public class Game {
String startTimeStr = resultSet.getString(6);
String endTimeStr = resultSet.getString(7);
game = new Game(resultSet.getLong(1),
User.selectUser(resultSet.getLong(2)),
UserDAO.selectUser(resultSet.getLong(2)),
GameDifficulty.getGameDifficultyForDifficultyNumber(resultSet.getInt(3)),
GameDefinition.getGameDefinitionForGameNumber(resultSet.getInt(4)),
new TablexiaRandom(resultSet.getLong(5)),
......
......@@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.List;
import cz.nic.tablexia.TablexiaStorage;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
......
......@@ -12,7 +12,8 @@ import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.trophy.GameTrophyDefinition;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
......@@ -73,7 +74,7 @@ public class GameTrophy {
String startTimeStr = resultSet.getString(6);
String endTimeStr = resultSet.getString(7);
games.add(new Game(resultSet.getLong(1),
User.selectUser(resultSet.getLong(2)),
UserDAO.selectUser(resultSet.getLong(2)),
GameDifficulty.getGameDifficultyForDifficultyNumber(resultSet.getInt(3)),
GameDefinition.getGameDefinitionForGameNumber(resultSet.getInt(4)),
new TablexiaRandom(resultSet.getLong(5)),
......
......@@ -21,7 +21,8 @@ import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.trophy.UserTrophyDefinition;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
/**
......@@ -166,7 +167,7 @@ public class UserTrophy {
String startTimeStr = resultSet.getString(6);
String endTimeStr = resultSet.getString(7);
games.add(new Game(resultSet.getLong(1),
User.selectUser(resultSet.getLong(2)),
UserDAO.selectUser(resultSet.getLong(2)),
GameDifficulty.getGameDifficultyForDifficultyNumber(resultSet.getInt(3)),
GameDefinition.getGameDefinitionForGameNumber(resultSet.getInt(4)),
new TablexiaRandom(resultSet.getLong(5)),
......
......@@ -42,7 +42,7 @@ import cz.nic.tablexia.loader.TablexiaDataManager;
import cz.nic.tablexia.loader.TablexiaSoundManager;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.Utility;
......
......@@ -40,7 +40,8 @@ import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.createuser.form.FormActorsLayout;
import cz.nic.tablexia.screen.createuser.form.SignatureDialog;
......@@ -303,7 +304,7 @@ public class FormScreen extends AbstractTablexiaScreen<Void> {
clearValidations();
validations.put(VALIDATION_STAMP, true);
stampIt();
User user = User.createUser(nameField.getText(), FormScreen.this.age, FormScreen.this.gender, mugshot, signature);
User user = UserDAO.createUser(nameField.getText(), FormScreen.this.age, FormScreen.this.gender, mugshot, signature);
TablexiaSettings.getInstance().setSelectedUser(user);
ApplicationBus.getInstance().post(new Tablexia.ChangeScreenEvent(TablexiaSettings.INITIAL_SCREEN, TablexiaApplication.ScreenTransaction.FADE)).asynchronously();
}
......@@ -348,7 +349,7 @@ public class FormScreen extends AbstractTablexiaScreen<Void> {
return false;
}
if (User.userNameExists(nameField.getText())) {
if (UserDAO.userNameExists(nameField.getText())) {
displayHintDialog(VALIDATION_USERNAME_EXISTS, nameField);
return false;
}
......
......@@ -16,7 +16,7 @@ import java.util.Map;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.menu.game.GameMenuDefinition;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.actions.ScrollHomeAction;
import cz.nic.tablexia.screen.gamemenu.event.ShowGameMenuPageEvent;
......@@ -150,7 +150,7 @@ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> {
public void run() {
pagedScrollPane.setTouchable(Touchable.enabled);
getSelectedUser().setIntro(false);
User.updateUser(getSelectedUser());
UserDAO.updateUser(getSelectedUser());
}
})));
}
......
......@@ -17,7 +17,8 @@ import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.encyclopedia.EncyclopediaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuAssets;
......@@ -109,7 +110,7 @@ public class OfficeMenuPage extends MenuPage {
//Have user seen the help overlay ?
if(TablexiaSettings.getInstance().getSelectedUser().isHelp()) {
TablexiaSettings.getInstance().getSelectedUser().setHelp(false);
User.updateUser(TablexiaSettings.getInstance().getSelectedUser());
UserDAO.updateUser(TablexiaSettings.getInstance().getSelectedUser());
toggleHelpOverlay();
}
......
......@@ -12,7 +12,7 @@ import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.screen.createuser.FormScreen;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
......
Subproject commit 965e91fb41c73b291946f5c105f8fdcadff912f8
Markdown is supported
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