Опциональные моды в runtime

This commit is contained in:
Gravit 2018-11-08 17:41:16 +07:00
parent 5ef915c00b
commit 06c94316dd
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 49 additions and 12 deletions

View file

@ -172,6 +172,7 @@ function goSettings(event) {
} }
// Show settings overlay // Show settings overlay
updateOptional();
overlay.show(settingsOverlay.overlay, null); overlay.show(settingsOverlay.overlay, null);
} }

View file

@ -4,24 +4,22 @@
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?> <?import javafx.scene.control.CheckBox?>
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.text.Text?> <?import javafx.scene.text.Text?>
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Pane id="holder" layoutX="171.0" layoutY="28.0" prefHeight="372.0" prefWidth="429.0"> <Pane id="holder" layoutX="171.0" layoutY="28.0" prefHeight="372.0" prefWidth="429.0">
<children> <children>
<CheckBox fx:id="modid_0" layoutX="14.0" layoutY="14.0" text="NEI" /> <Button fx:id="apply" defaultButton="true" layoutX="315.0" layoutY="333.0" prefHeight="25.0" prefWidth="100.0" text="Применить" />
<Button fx:id="apply" defaultButton="true" layoutX="315.0" layoutY="333.0" prefHeight="25.0" prefWidth="100.0" text="Применить" /> <FlowPane id="holderpane" orientation="HORIZONTAL">
<Text fill="#8c8c8c" layoutX="38.0" layoutY="29.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Включение авто-входа означает что вы сразу после загрузки клиента попадете на сервер" wrappingWidth="379.00000374019146" y="15.0" /> <children>
<CheckBox fx:id="modid_1" layoutX="14.0" layoutY="108.0" text="BetterFoliage" /> </children>
<CheckBox fx:id="modid_2" layoutX="14.0" layoutY="166.0" text="Schematica" /> </FlowPane>
<CheckBox fx:id="modid_3" layoutX="39.0" layoutY="73.0" text="NEI Addons" /> </children>
<Text fill="#8c8c8c" layoutX="38.0" layoutY="121.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Мод довольно сильно преобразит игру, мир обзаведется густой растительностью: изменится трава и листья" wrappingWidth="379.00000374019146" y="15.0" /> </Pane>
<Text fill="#8c8c8c" layoutX="38.0" layoutY="180.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Позволит вам смотреть файлы с расширением schematic прямо в вашем игровом мире" wrappingWidth="379.00000374019146" y="15.0" />
</children>
</Pane>
</children> </children>
<stylesheets> <stylesheets>
<URL value="@options.css" /> <URL value="@options.css" />

View file

@ -42,9 +42,45 @@ var options = {
// Lookup autoEnter checkbox // Lookup autoEnter checkbox
var holder = options.overlay.lookup("#holder"); var holder = options.overlay.lookup("#holder");
// Lookup apply settings button // Lookup apply settings button
holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null)); holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null));
}, },
}; };
function updateOptional()
{
var holder = options.overlay.lookup("#holderpane");
var nodelist = new java.util.ArrayList;
holder.getChildren().forEach(function(node,i,arr) {
if(node instanceof javafx.scene.control.CheckBox)
nodelist.add(node);
});
nodelist.forEach(function(node,i,arr) {
holder.getChildren().remove(node);
});
var profile = profilesList[serverHolder.old].object;
var list = profile.getOptional();
var checkboxlist = new java.util.ArrayList;
list.forEach(function(modfile,i,arr) {
var testMod = new javafx.scene.control.CheckBox(modfile.string);
testMod.setSelected(modfile.mark);
//testMod.setLayoutY(2+3*i);
//testMod.setLayoutX(2);
testMod.setOnAction(function(event) {
var isSelected = event.getSource().isSelected();
if(isSelected)
{
profile.markOptional(modfile.string);
LogHelper.debug("Selected mod %s", modfile.string);
}
else
{
profile.unmarkOptional(modfile.string);
LogHelper.debug("Unselected mod %s", modfile.string);
}
});
checkboxlist.add(testMod);
});
holder.getChildren().addAll(checkboxlist);
}

View file

@ -76,7 +76,9 @@ public String toString() {
private final IntegerConfigEntry serverPort; private final IntegerConfigEntry serverPort;
public static class MarkedString { public static class MarkedString {
@LauncherAPI
public String string; public String string;
@LauncherAPI
public boolean mark; public boolean mark;
public MarkedString(String string, boolean mark) { public MarkedString(String string, boolean mark) {