package seedu.watodo.model;

import java.util.HashMap;
import java.util.Objects;

import seedu.watodo.commons.core.GuiSettings;
import seedu.watodo.logic.commands.AlternativeCommandsLibrary;

/**
 * Represents User's preferences.
 */
public class UserPrefs {

    public GuiSettings guiSettings;
    public HashMap<String, String> alternativeCommands;

    //@@author A0143076J
    public HashMap<String, String> getAlternativeCommands() {
        return alternativeCommands == null ? AlternativeCommandsLibrary.altCommands : alternativeCommands;
    }

    public void updateLastestAlternativeCommandsLib(HashMap<String, String> alternativeCommands) {
        this.alternativeCommands = alternativeCommands;
    }

    //@@author
    public GuiSettings getGuiSettings() {
        return guiSettings == null ? new GuiSettings() : guiSettings;
    }

    public void updateLastUsedGuiSetting(GuiSettings guiSettings) {
        this.guiSettings = guiSettings;
    }

    public UserPrefs() {
        this.setGuiSettings(500, 500, 0, 0);
        this.alternativeCommands = AlternativeCommandsLibrary.altCommands;
    }

    public void setGuiSettings(double width, double height, int x, int y) {
        guiSettings = new GuiSettings(width, height, x, y);
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if (!(other instanceof UserPrefs)) { //this handles null as well.
            return false;
        }

        UserPrefs o = (UserPrefs) other;

        return Objects.equals(guiSettings, o.guiSettings);
    }

    @Override
    public int hashCode() {
        return Objects.hash(guiSettings);
    }

    @Override
    public String toString() {
        return guiSettings.toString();
    }

}
