Skip to content

Commit

Permalink
WPR-10 - Fix callsign error, adjust heading from radians, add speed t…
Browse files Browse the repository at this point in the history
…o unit details. reduce install size
  • Loading branch information
nadav-yo committed Jan 22, 2024
1 parent 9ef1cba commit 64ae4b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
<artifactId>spring-boot-starter</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jna</artifactId>
<version>3.24.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/org/faulty/wpreplace/models/UnitDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -17,7 +19,8 @@ public class UnitDetails {
private final float x;
private final float y;
private final int alt;
private final float heading;
private final BigDecimal heading;
private final float speed;
private final LuaTable luaUnit;

public static List<UnitDetails> fromLuaGroup(LuaTable luaGroup) {
Expand All @@ -34,15 +37,20 @@ public static List<UnitDetails> fromLuaGroup(LuaTable luaGroup) {
luaUnit.get("x").tofloat(),
luaUnit.get("y").tofloat(),
luaUnit.get("alt").toint(),
luaUnit.get("heading").tofloat(),
BigDecimal.valueOf(Math.toDegrees(luaUnit.get("heading").tofloat())).setScale(1, RoundingMode.HALF_UP),
luaUnit.get("speed").tofloat(),
luaUnit)
);
}
return unitDetails;
}

private static String getCallsigns(LuaTable luaGroup) {
LuaTable callsign = luaGroup.get("callsign").checktable();
LuaValue callsignVal = luaGroup.get("callsign");
if (callsignVal.isint()) {
return Integer.toString(callsignVal.toint());
}
LuaTable callsign = callsignVal.checktable();
List<String> callSigns = new ArrayList<>();
for (LuaValue key : callsign.keys()) {
if (callsign.get(key).isstring()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.math.BigDecimal;

@Log4j2
@Component
Expand Down Expand Up @@ -66,13 +67,15 @@ public void setGroup(String coalition, int countryId, String unitType, int group
yColumn.setCellValueFactory(new PropertyValueFactory<>("y"));
TableColumn<UnitDetails, Integer> altColumn = new TableColumn<>("Alt");
altColumn.setCellValueFactory(new PropertyValueFactory<>("alt"));
TableColumn<UnitDetails, Float> headingColumn = new TableColumn<>("Heading");
TableColumn<UnitDetails, BigDecimal> headingColumn = new TableColumn<>("Heading");
headingColumn.setCellValueFactory(new PropertyValueFactory<>("heading"));
TableColumn<UnitDetails, Float> speedColumn = new TableColumn<>("Speed");
speedColumn.setCellValueFactory(new PropertyValueFactory<>("speed"));

TableColumn<UnitDetails, Void> viewColumn = new TableColumn<>("View Payload");
viewColumn.setCellFactory(createButtonCellFactory());

dataTable.getColumns().addAll(idColumn, nameColumn, skillColumn, callSignsColumn, unitColumn, xColumn, yColumn, altColumn, headingColumn, viewColumn);
dataTable.getColumns().addAll(idColumn, nameColumn, skillColumn, callSignsColumn, unitColumn, xColumn, yColumn, altColumn, headingColumn, speedColumn, viewColumn);

dataTable.setItems(routes);
idColumn.setSortType(TableColumn.SortType.ASCENDING);
Expand Down

0 comments on commit 64ae4b7

Please sign in to comment.