Skip to content

Commit 4de1f66

Browse files
committed
almighty push
0 parents  commit 4de1f66

15 files changed

+919
-0
lines changed

libs/ConfigurationAPI-1.4.jar

38.5 KB
Binary file not shown.

src/drzed/Ability.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package drzed;
2+
3+
public class Ability {
4+
public String name;
5+
public String ID;
6+
public double baseDamage;
7+
public double Damage;
8+
public int hits;
9+
10+
public Ability() {}
11+
12+
public Ability(String nm, String id) {
13+
name = nm;
14+
ID = id;
15+
hits = 0;
16+
}
17+
18+
public void updateBaseDamage(double dm) {
19+
baseDamage = (baseDamage + dm) / 2f;
20+
}
21+
22+
public void updateDamage(double dm) {
23+
Damage += dm;
24+
hits++;
25+
}
26+
}

src/drzed/Configs.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package drzed;
2+
3+
import hxckdms.hxcconfig.Config;
4+
5+
@Config
6+
public class Configs {
7+
public static int combatLogPollRate = 1000;
8+
public static String combatLogFolder = "A:/Games/Magic Legends_en/Magic Legends/Live/logs/GameClient";
9+
public static String theme = "dark";
10+
public static int endEncounterTimer = 120000;
11+
public static String defaultFilter = "Keldon Warlord";
12+
public static int guiPollRate = 15;
13+
}

src/drzed/Controller.java

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
package drzed;
2+
3+
import javafx.application.Platform;
4+
import javafx.collections.FXCollections;
5+
import javafx.collections.ObservableList;
6+
import javafx.concurrent.Task;
7+
import javafx.event.ActionEvent;
8+
import javafx.event.EventHandler;
9+
import javafx.fxml.FXML;
10+
import javafx.geometry.Side;
11+
import javafx.scene.chart.LineChart;
12+
import javafx.scene.chart.PieChart;
13+
import javafx.scene.control.*;
14+
import javafx.scene.input.MouseEvent;
15+
import javafx.stage.FileChooser;
16+
17+
import java.io.IOException;
18+
19+
@SuppressWarnings("all")
20+
public class Controller {
21+
22+
@FXML
23+
public LineChart lineChart;
24+
@FXML
25+
public MenuItem themeB;
26+
@FXML
27+
public MenuItem aboutB;
28+
@FXML
29+
public MenuItem fileB;
30+
@FXML
31+
public MenuItem closeB;
32+
@FXML
33+
public PieChart pieChart = new PieChart();
34+
@FXML
35+
public TableView<DataEntity> table = new TableView<DataEntity>();
36+
@FXML
37+
public TableView<DataAbility> statsTbl = new TableView<DataAbility>();
38+
39+
@FXML
40+
public TableColumn<DataEntity, String> nameCol = new TableColumn("Name");
41+
@FXML
42+
public TableColumn<DataEntity, String> damageCol = new TableColumn("Damage");
43+
@FXML
44+
public TableColumn<DataEntity, String> dpsCol = new TableColumn("DPS");
45+
@FXML
46+
public TableColumn<DataEntity, String> healCol = new TableColumn("Heal");
47+
@FXML
48+
public TableColumn<DataEntity, String> hpscol = new TableColumn("HPS");
49+
@FXML
50+
public TableColumn<DataEntity, String> takenCol = new TableColumn("Taken");
51+
@FXML
52+
public TableColumn<DataEntity, String> deathCol = new TableColumn("Death");
53+
@FXML
54+
public TableColumn<DataEntity, String> durationCol = new TableColumn("Time");
55+
@FXML
56+
public TableColumn<DataEntity, String> hitsCol = new TableColumn("Hits");
57+
58+
@FXML
59+
public TableColumn<DataAbility, String> abilityCol = new TableColumn<>("Ability");
60+
@FXML
61+
public TableColumn<DataAbility, String> basedmgCol = new TableColumn<>("Base DMG");
62+
@FXML
63+
public TableColumn<DataAbility, String> damageCol2 = new TableColumn<>("Damage");
64+
@FXML
65+
public TableColumn<DataAbility, String> dpsCol2 = new TableColumn<>("DPH");
66+
@FXML
67+
public TableColumn<DataAbility, String> hitsCol2 = new TableColumn<>("Hits");
68+
@FXML
69+
public Button quitBtn;
70+
71+
public static ObservableList<DataEntity> dataEntities = FXCollections.observableArrayList();
72+
public static ObservableList<DataAbility> dataAbilities = FXCollections.observableArrayList();
73+
private static ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
74+
75+
public Controller() {
76+
table.setEditable(false);
77+
statsTbl.setEditable(false);
78+
79+
table.getColumns().addAll(nameCol, damageCol, dpsCol, healCol, hpscol, takenCol, deathCol, durationCol, hitsCol);
80+
statsTbl.getColumns().addAll(abilityCol, basedmgCol, damageCol2, dpsCol2, hitsCol2);
81+
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
82+
statsTbl.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
83+
table.setItems(dataEntities);
84+
statsTbl.setItems(dataAbilities);
85+
pieChart.setLabelsVisible(false);
86+
pieChart.setStartAngle(180);
87+
pieChart.setClockwise(true);
88+
}
89+
90+
@FXML
91+
private void initialize() {
92+
Task task = new Task<Void>() {
93+
@Override public Void call() {
94+
while (true) {
95+
update();
96+
}
97+
}
98+
};
99+
new Thread(task).start();
100+
}
101+
102+
private static Encounter current;
103+
private static long tmin = 0;
104+
private static DataEntity fil;
105+
public void update() {
106+
if (System.currentTimeMillis() - tmin < Configs.guiPollRate) return;
107+
try {
108+
MagicParser.ParseFile();
109+
if (current == null && MagicParser.getCurrentEncounter() != null) {
110+
current = MagicParser.getCurrentEncounter();
111+
Platform.runLater(() -> pieChart.getData().clear());
112+
} else if (current != null && MagicParser.getCurrentEncounter() != null && current != MagicParser.getCurrentEncounter()) {
113+
current = MagicParser.getCurrentEncounter();
114+
Platform.runLater(() -> pieChart.getData().clear());
115+
}
116+
if (current == null) return;
117+
} catch (IOException | InterruptedException e) {
118+
e.printStackTrace();
119+
}
120+
121+
if (dataEntities.size() != current.entities.size()) {
122+
dataEntities = FXCollections.observableArrayList();
123+
dataAbilities = FXCollections.observableArrayList();
124+
for (Entity value : current.entities.values()) {
125+
DataEntity de = new DataEntity(value);
126+
if (value.name.equalsIgnoreCase(Configs.defaultFilter)) {
127+
fil = de;
128+
}
129+
dataEntities.add(de);
130+
}
131+
132+
table.getItems().removeAll();
133+
134+
nameCol.setCellValueFactory(cellData -> cellData.getValue().getEntityName());
135+
damageCol.setCellValueFactory(cellData -> cellData.getValue().getEntityDamage());
136+
dpsCol.setCellValueFactory(cellData -> cellData.getValue().getEntityDPS());
137+
healCol.setCellValueFactory(cellData -> cellData.getValue().getEntityHealing());
138+
hpscol.setCellValueFactory(cellData -> cellData.getValue().getEntityHPS());
139+
takenCol.setCellValueFactory(cellData -> cellData.getValue().getEntityTaken());
140+
deathCol.setCellValueFactory(cellData -> cellData.getValue().getEntityDeaths());
141+
durationCol.setCellValueFactory(cellData -> cellData.getValue().getEntityLifetime());
142+
hitsCol.setCellValueFactory(cellData -> cellData.getValue().getEntityHits());
143+
144+
table.setItems(dataEntities);
145+
146+
statsTbl.getItems().removeAll();
147+
if (fil != null) {
148+
table.getSelectionModel().select(fil);
149+
// System.out.println(table.getSelectionModel().getSelectedIndex());
150+
}
151+
if (table.getSelectionModel().getSelectedIndex() != -1) {
152+
Entity ent = current.getEntity(table.getSelectionModel().getSelectedItem().entityID);
153+
if (ent.abilities.size() > 0) {
154+
for (Ability value : ent.abilities.values()) {
155+
dataAbilities.add(new DataAbility(value));
156+
}
157+
abilityCol.setCellValueFactory(cellData -> cellData.getValue().getAbilityName());
158+
basedmgCol.setCellValueFactory(cellData -> cellData.getValue().getAbilityBaseDamage());
159+
damageCol2.setCellValueFactory(cellData -> cellData.getValue().getAbilityDamage());
160+
dpsCol2.setCellValueFactory(cellData -> cellData.getValue().getAbilityDPS());
161+
hitsCol2.setCellValueFactory(cellData -> cellData.getValue().getAbilityHits());
162+
statsTbl.setItems(dataAbilities);
163+
}
164+
165+
if (dataAbilities.size() > 0) {
166+
for (DataAbility dataAbility : dataAbilities) {
167+
Platform.runLater(() -> addData(dataAbility.abilityName, dataAbility.abilityDamage));
168+
// if (pieChart.getData().isEmpty()) {
169+
// pieChart.setData(pieChartData);
170+
// }
171+
}
172+
} else {
173+
// pieChartData.clear();
174+
Platform.runLater(() -> pieChart.getData().clear());
175+
}
176+
}
177+
}
178+
179+
tmin = System.currentTimeMillis();
180+
}
181+
182+
//adds new Data to the list
183+
public void naiveAddData(String name, double value) {
184+
pieChart.getData().add(new PieChart.Data(name, value));
185+
pieChart.setLabelsVisible(false);
186+
pieChart.setLabelLineLength(0);
187+
pieChart.setLegendSide(Side.LEFT);
188+
}
189+
190+
//updates existing Data-Object if name matches
191+
public void addData(String name, double value)
192+
{
193+
for(PieChart.Data d : pieChart.getData())
194+
{
195+
if(d.getName().equals(name))
196+
{
197+
d.setPieValue(value);
198+
pieChart.setLabelsVisible(false);
199+
pieChart.setLabelLineLength(0);
200+
return;
201+
}
202+
}
203+
naiveAddData(name, value);
204+
}
205+
206+
public void onFile(ActionEvent actionEvent) {
207+
FileChooser chooser = new FileChooser();
208+
Main.Directory = chooser.showOpenDialog(Main.stage);
209+
}
210+
211+
public void onTheme(ActionEvent actionEvent) {
212+
213+
}
214+
215+
public void onAbout(ActionEvent actionEvent) {
216+
217+
}
218+
219+
220+
public void quit(ActionEvent actionEvent) {
221+
Platform.exit();
222+
System.exit(0);
223+
}
224+
225+
public void close(ActionEvent actionEvent) {
226+
Platform.exit();
227+
System.exit(0);
228+
}
229+
230+
double xOffset, yOffset;
231+
public void onMouseDrag(MouseEvent mouseEvent) {
232+
Main.stage.setX(mouseEvent.getScreenX() + xOffset);
233+
Main.stage.setY(mouseEvent.getScreenY() + yOffset);
234+
}
235+
236+
public void mousePress(MouseEvent mouseEvent) {
237+
xOffset = Main.stage.getX() - mouseEvent.getScreenX();
238+
yOffset = Main.stage.getY() - mouseEvent.getScreenY();
239+
}
240+
}

src/drzed/DataAbility.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package drzed;
2+
3+
import javafx.beans.property.SimpleStringProperty;
4+
import javafx.beans.property.StringProperty;
5+
6+
@SuppressWarnings("WeakerAccess")
7+
public class DataAbility {
8+
public double abilityDamage;
9+
public double abilityDPS;
10+
public double abilityHits;
11+
public String abilityName;
12+
public String abilityID;
13+
public double abilityBaseDamage;
14+
15+
public DataAbility() {}
16+
17+
public DataAbility(Ability ab) {
18+
abilityDamage = ab.Damage;
19+
abilityHits = ab.hits;
20+
abilityDPS = ab.Damage / abilityHits;
21+
abilityName = ab.name;
22+
abilityID = ab.ID;
23+
abilityBaseDamage = ab.baseDamage;
24+
}
25+
26+
public StringProperty getAbilityName() {
27+
return new SimpleStringProperty(abilityName);
28+
}
29+
public StringProperty getAbilityID() {
30+
return new SimpleStringProperty(abilityID);
31+
}
32+
public StringProperty getAbilityDamage() {
33+
return new SimpleStringProperty(String.format("%1$,.1f", abilityDamage));
34+
}
35+
public StringProperty getAbilityBaseDamage() {
36+
return new SimpleStringProperty(String.format("%1$,.1f", abilityBaseDamage));
37+
}
38+
public StringProperty getAbilityDPS() {
39+
return new SimpleStringProperty(String.format("%1$,.1f", abilityDPS));
40+
}
41+
public StringProperty getAbilityHits() {
42+
return new SimpleStringProperty(String.valueOf(abilityHits));
43+
}
44+
}

0 commit comments

Comments
 (0)