-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPR-11 - Add radio, datalink link16 and icons
- Loading branch information
Showing
16 changed files
with
259 additions
and
10 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/org/faulty/wpreplace/models/UnitDataLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.faulty.wpreplace.models; | ||
|
||
import jakarta.annotation.Nullable; | ||
import lombok.Data; | ||
import org.faulty.wpreplace.utils.LuaWriter; | ||
import org.luaj.vm2.LuaTable; | ||
import org.luaj.vm2.LuaValue; | ||
|
||
@Data | ||
public class UnitDataLink { | ||
|
||
private final String type; | ||
private final String Link16; | ||
|
||
@Nullable | ||
public static UnitDataLink fromLuaGroup(LuaTable luaUnit) { | ||
LuaValue datalinks = luaUnit.get("datalinks"); | ||
if (datalinks.isnil()) { | ||
return null; | ||
} | ||
LuaTable link16 = datalinks.checktable().get("Link16").checktable(); | ||
return new UnitDataLink( | ||
luaUnit.get("type").tojstring(), | ||
LuaWriter.luaTableToString(link16) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.faulty.wpreplace.models; | ||
|
||
import lombok.Data; | ||
import org.luaj.vm2.LuaTable; | ||
import org.luaj.vm2.LuaValue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Data | ||
public class UnitRadio { | ||
private final String type; | ||
private final List<Channel> channels1; | ||
private final List<Channel> channels2; | ||
|
||
public static UnitRadio fromLuaGroup(LuaTable luaUnit) { | ||
LuaValue radio = luaUnit.get("Radio"); | ||
if (radio.isnil()) { | ||
return null; | ||
} | ||
LuaTable radios = radio.checktable(); | ||
return new UnitRadio( | ||
luaUnit.get("type").tojstring(), | ||
getChannels(radios, 1), | ||
getChannels(radios, 2) | ||
); | ||
} | ||
|
||
private static List<Channel> getChannels(LuaTable unitRadios, int radio) { | ||
List<Channel> radioChannels = new ArrayList<>(); | ||
LuaTable channels = unitRadios.get(radio).checktable().get("channels").checktable(); | ||
for (LuaValue key : channels.keys()) { | ||
LuaValue channel = channels.get(key); | ||
if (channel.isint()) { | ||
radioChannels.add(new Channel(key.toint(), channel.toint())); | ||
} | ||
} | ||
return radioChannels; | ||
} | ||
|
||
@Data | ||
public static final class Channel { | ||
private final int index; | ||
private final int frequency; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/org/faulty/wpreplace/ui/DataLinkController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.faulty.wpreplace.ui; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.text.Text; | ||
import lombok.Data; | ||
import org.faulty.wpreplace.models.UnitDataLink; | ||
|
||
public class DataLinkController { | ||
@FXML | ||
public Label typeLabel; | ||
public Text link16Details; | ||
|
||
|
||
public void initialize(UnitDataLink data) { | ||
typeLabel.setText("Type: " + data.getType()); | ||
|
||
link16Details.setText("Link16:" + data.getLink16()); | ||
|
||
} | ||
|
||
@Data | ||
public static final class Item { | ||
private final String type; | ||
private final int quantity; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/faulty/wpreplace/ui/RadioController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.faulty.wpreplace.ui; | ||
|
||
import javafx.collections.FXCollections; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import org.faulty.wpreplace.models.UnitRadio; | ||
|
||
import java.util.List; | ||
|
||
public class RadioController { | ||
@FXML | ||
public Label typeLabel; | ||
|
||
@FXML | ||
private TableView<UnitRadio.Channel> radio1ListView; | ||
@FXML | ||
private TableView<UnitRadio.Channel> radio2ListView; | ||
|
||
|
||
public void initialize(UnitRadio data) { | ||
typeLabel.setText("Type: " + data.getType()); | ||
|
||
addRadioChannels(radio1ListView, data.getChannels1()); | ||
addRadioChannels(radio2ListView, data.getChannels2()); | ||
} | ||
|
||
private void addRadioChannels(TableView<UnitRadio.Channel> tableView, List<UnitRadio.Channel> channels) { | ||
TableColumn<UnitRadio.Channel, Integer> indexColumn = new TableColumn<>("Channel #"); | ||
indexColumn.setCellValueFactory(new PropertyValueFactory<>("index")); | ||
TableColumn<UnitRadio.Channel, Integer> freqColumn = new TableColumn<>("Channel Freq"); | ||
freqColumn.setCellValueFactory(new PropertyValueFactory<>("frequency")); | ||
tableView.getColumns().addAll(indexColumn, freqColumn); | ||
tableView.setItems(FXCollections.observableArrayList(channels)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/resources/org/faulty/wpreplace/ui/DataLinkDetails.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.text.Text?> | ||
<VBox xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" | ||
fx:controller="org.faulty.wpreplace.ui.DataLinkController"> | ||
<HBox alignment="CENTER" spacing="10"> | ||
<Label fx:id="typeLabel" alignment="CENTER"/> | ||
</HBox> | ||
<Text fx:id="link16Details" text="Link 16 details"/> | ||
</VBox> |
17 changes: 17 additions & 0 deletions
17
src/main/resources/org/faulty/wpreplace/ui/RadioDetails.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TableView?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.text.Text?> | ||
<VBox xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" | ||
fx:controller="org.faulty.wpreplace.ui.RadioController"> | ||
<HBox alignment="CENTER" spacing="10"> | ||
<Label fx:id="typeLabel" alignment="CENTER"/> | ||
</HBox> | ||
<Text text="Radio 1 Channels"/> | ||
<TableView fx:id="radio1ListView" maxHeight="100"/> | ||
<Text text="Radio 2 Channels"/> | ||
<TableView fx:id="radio2ListView" maxHeight="100"/> | ||
</VBox> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.