package app.lsgui.gui.chat;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import app.lsgui.gui.settings.SettingsWindow;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class ChatWindow {

    private static final Logger LOGGER = LoggerFactory.getLogger(SettingsWindow.class);
    private Stage chatStage;
    private String channel;
    private FXMLLoader loader;

    public ChatWindow(final String channel) {
        this.channel = channel;
        chatStage = new Stage();

        loader = new FXMLLoader(getClass().getClassLoader().getResource("fxml/ChatWindow.fxml"));
        Parent root = loadFXML();
        setupStage(root, chatStage);
    }

    private Parent loadFXML() {
        try {
            return loader.load();
        } catch (IOException e) {
            LOGGER.error("ERROR while loading chat fxml", e);
            Platform.exit();
            return null;
        }
    }

    private void setupStage(final Parent root, final Stage chatStage) {
        Scene scene = new Scene(root);
        scene.getStylesheets().add(getClass().getResource("/lightStyle.css").toString());

        chatStage.setMinHeight(400.0);
        chatStage.setMinWidth(600.0);

        chatStage.getProperties().put("channel", channel);
        chatStage.setTitle("Livestreamer GUI v3.0 Chat - " + channel);
        chatStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.jpg")));
        chatStage.setScene(scene);
        chatStage.initModality(Modality.NONE);
        chatStage.show();

        chatStage.setOnCloseRequest(event -> ((ChatController) loader.getController()).disconnect());
    }

    public void connect() {
        loader.<ChatController> getController().connect();
    }

}

@@ -141,31 +141,101 @@
 gui.
-settings.SettingsWindow
+MainWindow;%0D%0Aimport app.lsgui.gui.settings.SettingsWindow;%0D%0Aimport app.lsgui.service.Settings
 ;%0D%0Ai
@@ -1371,58 +1371,129 @@
 add(
-getClass().getResource(%22/lightStyle.css%22).toString
+ChatWindow.class%0D%0A                .getResource(%22/styles/%22 + Settings.instance().getWindowStyle() + %22.css%22).toExternalForm
 ());

add stylesheet