<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.*?>
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.*?>
<?import org.jackhuang.hmcl.ui.construct.*?>
<?import org.jackhuang.hmcl.ui.*?>
<fx:root xmlns="http://javafx.com/javafx"
         xmlns:fx="http://javafx.com/fxml"
         type="StackPane">
    <ScrollPane fx:id="scroll" fitToHeight="true" fitToWidth="true" vbarPolicy="ALWAYS">
        <VBox fx:id="rootPane" style="-fx-padding: 20;" spacing="12">

            <ComponentList fx:id="iconPickerItemWrapper">
                <ImagePickerItem fx:id="iconPickerItem" title="%settings.icon" onSelectButtonClicked="#onExploreIcon" onDeleteButtonClicked="#onDeleteIcon">
                    <Image url="/assets/img/icon.png"/>
                </ImagePickerItem>
            </ComponentList>

            <BorderPane fx:id="settingsTypePane">
                <left>
                    <JFXCheckBox BorderPane.alignment="CENTER_RIGHT" fx:id="chkEnableSpecificSettings" text="%settings.type.special.enable" />
                </left>
                <right>
                    <JFXButton BorderPane.alignment="CENTER_RIGHT" onMouseClicked="#editGlobalSettings"
                               buttonType="RAISED" styleClass="jfx-button-raised"
                               text="%settings.type.global.edit" disable="${chkEnableSpecificSettings.selected}" />
                </right>
            </BorderPane>

            <ComponentList fx:id="componentList" depth="1">

                <MultiFileItem fx:id="javaItem" title="%settings.game.java_directory" chooserTitle="%settings.game.java_directory.choose"
                               hasSubtitle="true" customText="%settings.custom" directory="false" />

                <MultiFileItem fx:id="gameDirItem" title="%settings.game.working_directory" chooserTitle="%settings.game.working_directory.choose"
                               hasSubtitle="true" customText="%settings.custom" directory="true" />

                <BorderPane> <!-- Max Memory -->
                    <left>
                        <VBox>
                            <Label text="%settings.max_memory" BorderPane.alignment="CENTER_LEFT"/>
                            <Label fx:id="lblPhysicalMemory" styleClass="subtitle-label"/>
                        </VBox>
                    </left>
                    <right>
                        <JFXTextField fx:id="txtMaxMemory" BorderPane.alignment="CENTER_RIGHT" FXUtils.validateWhileTextChanged="true" FXUtils.limitWidth="300">
                            <validators>
                                <NumberValidator message="%input.number" nullable="false" />
                            </validators>
                        </JFXTextField>
                    </right>
                </BorderPane>

                <BorderPane> <!-- Launcher Visibility -->
                    <left>
                        <Label text="%settings.advanced.launcher_visible" BorderPane.alignment="CENTER_LEFT"/>
                    </left>
                    <right>
                        <JFXComboBox fx:id="cboLauncherVisibility" BorderPane.alignment="CENTER_RIGHT" FXUtils.limitWidth="300" />
                    </right>
                </BorderPane>

                <BorderPane> <!-- Dimension -->
                    <left>
                        <Label text="%settings.game.dimension" BorderPane.alignment="CENTER_LEFT"/>
                    </left>
                    <right>
                        <BorderPane>
                            <left>
                                <HBox prefWidth="210" spacing="3" alignment="CENTER" BorderPane.alignment="CENTER">
                                    <JFXTextField fx:id="txtWidth" promptText="800" prefWidth="100" FXUtils.validateWhileTextChanged="true">
                                        <validators>
                                            <NumberValidator message="%input.number" nullable="false" />
                                        </validators>
                                    </JFXTextField>
                                    <Label>x</Label>
                                    <JFXTextField fx:id="txtHeight" promptText="480" prefWidth="100" FXUtils.validateWhileTextChanged="true">
                                        <validators>
                                            <NumberValidator message="%input.number" nullable="false" />
                                        </validators>
                                    </JFXTextField>
                                </HBox>
                            </left>
                            <right>
                                <JFXCheckBox fx:id="chkFullscreen" text="%settings.game.fullscreen" alignment="CENTER"
                                             BorderPane.alignment="CENTER">
                                    <BorderPane.margin>
                                        <Insets right="7"/>
                                    </BorderPane.margin>
                                </JFXCheckBox>
                            </right>
                        </BorderPane>
                    </right>
                </BorderPane>

                <BorderPane>
                    <left>
                        <Label BorderPane.alignment="CENTER_LEFT" text="%settings.show_log"/>
                    </left>
                    <right>
                        <JFXToggleButton fx:id="chkShowLogs" size="8" FXUtils.limitHeight="20" />
                    </right>
                </BorderPane>
            </ComponentList>
            <HBox alignment="CENTER_LEFT" style="-fx-padding: 8 0 0 0;">
                <Label text="%settings.advanced" style="-fx-text-fill: #616161;" />
            </HBox>
            <ComponentList fx:id="advancedSettingsPane" depth="1">
                <JFXTextField labelFloat="true" promptText="%settings.advanced.jvm_args" styleClass="fit-width"
                              fx:id="txtJVMArgs">
                    <tooltip>
                        <Tooltip text="%settings.advanced.java_args_default"/>
                    </tooltip>
                </JFXTextField>
                <fx:define>
                    <Insets fx:id="insets" bottom="8"/>
                </fx:define>
                <JFXTextField labelFloat="true" promptText="%settings.advanced.minecraft_arguments"
                              styleClass="fit-width" fx:id="txtGameArgs" StackPane.margin="$insets"/>
                <JFXTextField labelFloat="true" promptText="%settings.advanced.java_permanent_generation_space"
                              styleClass="fit-width" fx:id="txtMetaspace" StackPane.margin="$insets" FXUtils.validateWhileTextChanged="true">
                    <validators>
                        <NumberValidator message="%input.number" nullable="true" />
                    </validators>
                </JFXTextField>
                <JFXTextField labelFloat="true" promptText="%settings.advanced.wrapper_launcher" styleClass="fit-width"
                              fx:id="txtWrapper" StackPane.margin="$insets"/>
                <JFXTextField labelFloat="true" promptText="%settings.advanced.precall_command" styleClass="fit-width"
                              fx:id="txtPrecallingCommand" StackPane.margin="$insets"/>
                <JFXTextField labelFloat="true" promptText="%settings.advanced.server_ip" styleClass="fit-width"
                              fx:id="txtServerIP" StackPane.margin="$insets"/>
                <BorderPane>
                    <left>
                        <Label BorderPane.alignment="CENTER_LEFT" text="%settings.advanced.no_jvm_args"/>
                    </left>
                    <right>
                        <JFXToggleButton fx:id="chkNoJVMArgs" size="8" FXUtils.limitHeight="20" />
                    </right>
                </BorderPane>
                <BorderPane>
                    <left>
                        <Label BorderPane.alignment="CENTER_LEFT" text="%settings.advanced.dont_check_game_completeness"/>
                    </left>
                    <right>
                        <JFXToggleButton fx:id="chkNoGameCheck" size="8" FXUtils.limitHeight="20" />
                    </right>
                </BorderPane>
                <BorderPane>
                    <left>
                        <Label BorderPane.alignment="CENTER_LEFT" text="%settings.advanced.dont_check_jvm_validity"/>
                    </left>
                    <right>
                        <JFXToggleButton fx:id="chkNoJVMCheck" size="8" FXUtils.limitHeight="20" />
                    </right>
                </BorderPane>
            </ComponentList>
        </VBox>
    </ScrollPane>
</fx:root>
