Skip to content

Commit

Permalink
Fix Selection on Map
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeCrazyCoder committed Nov 28, 2020
1 parent 6634508 commit a09bab6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ private void transferToSelectionTool() {
//none
return;
}
DSWorkbenchSelectionFrame.getSingleton().addVillages(villages);
DSWorkbenchSelectionFrame.getSingleton().updateSelection(villages);
showInfo(villages.size() + ((villages.size() == 1) ? " Dorf" : " Dörfer") + " in die Auswahlübersicht übertragen");
}

Expand Down
13 changes: 8 additions & 5 deletions Core/src/main/java/de/tor/tribes/ui/panels/MapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void mouseClicked(MouseEvent e) {
markedVillages.remove(v);
}
}
DSWorkbenchSelectionFrame.getSingleton().addVillages(markedVillages);
DSWorkbenchSelectionFrame.getSingleton().updateSelection(markedVillages);
return;
}

Expand Down Expand Up @@ -721,11 +721,11 @@ public void mouseReleased(MouseEvent e) {
int ys = (int) Math.floor(selectionRect.getYPos());
int xe = (int) Math.floor(selectionRect.getXPosEnd());
int ye = (int) Math.floor(selectionRect.getYPosEnd());

//notify selection listener (see DSWorkbenchSelectionFrame)
if (!shiftDown) {
DSWorkbenchSelectionFrame.getSingleton().fireSelectionFinishedEvent(new Point(xs, ys), new Point(xe, ye));
if(xs == xe && ys == ye) {
//single village selection is handled by mouseClicked
break;
}

List<Village> villages = DataHolder.getSingleton().getVillagesInRegion(new Point(xs, ys), new Point(xe, ye));
for (Village v : villages) {
if (!markedVillages.contains(v)) {
Expand All @@ -735,6 +735,9 @@ public void mouseReleased(MouseEvent e) {
if (!markedVillages.isEmpty()) {
DSWorkbenchMainFrame.getSingleton().showInfo(((markedVillages.size() == 1) ? "Dorf " : markedVillages.size() + " Dörfer ") + "in die Auswahlübersicht übertragen");
}
//notify selection listener (see DSWorkbenchSelectionFrame)
DSWorkbenchSelectionFrame.getSingleton().updateSelection(markedVillages);

selectionRect = null;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.7" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
Expand Down Expand Up @@ -278,6 +278,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
Expand All @@ -297,7 +298,6 @@
<Component class="javax.swing.JCheckBox" name="jAlwaysOnTopBox">
<Properties>
<Property name="text" type="java.lang.String" value="Immer im Vordergrund"/>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="fireAlwaysOnTopChangedEvent"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import de.tor.tribes.util.UIHelper;
import de.tor.tribes.util.bb.VillageListFormatter;
import de.tor.tribes.util.html.SelectionHTMLExporter;
import de.tor.tribes.util.interfaces.VillageSelectionListener;
import de.tor.tribes.util.tag.TagManager;
import java.awt.BorderLayout;
import java.awt.Color;
Expand Down Expand Up @@ -82,7 +81,7 @@
/**
* @author Charon
*/
public class DSWorkbenchSelectionFrame extends AbstractDSWorkbenchFrame implements VillageSelectionListener, ActionListener, TreeSelectionListener {
public class DSWorkbenchSelectionFrame extends AbstractDSWorkbenchFrame implements ActionListener, TreeSelectionListener {

@Override
public void valueChanged(TreeSelectionEvent e) {
Expand Down Expand Up @@ -500,7 +499,7 @@ private void pasteFromInternalClipboard() {
if (villages == null || villages.isEmpty()) {
showInfo("Keine Dörfer in der Zwischenablage gefunden");
} else {
addVillages(villages);
updateSelection(villages);
showSuccess(((villages.size() == 1) ? "Dorf" : villages.size() + " Dörfer") + " eingefügt");
}
}
Expand Down Expand Up @@ -882,7 +881,7 @@ private void firePerformRegionSelectionEvent(java.awt.event.MouseEvent evt) {//G
+ "Die Auswahl k&ouml;nnte so sehr lange dauern. Bitte verkleinere den gew&auml;hlten Bereich.");
} else {
List<Village> selection = DataHolder.getSingleton().getVillagesInRegion(start, end);
addVillages(selection);
updateSelection(selection);
}
}

Expand Down Expand Up @@ -968,7 +967,7 @@ public List<Village> getSelectedElements() {

@Override
public void fireVillagesDraggedEvent(List<Village> pVillages, Point pDropLocation) {
addVillages(pVillages);
updateSelection(pVillages);
}

// Variables declaration - do not modify//GEN-BEGIN:variables
Expand Down Expand Up @@ -996,12 +995,13 @@ public void fireVillagesDraggedEvent(List<Village> pVillages, Point pDropLocatio
private org.jdesktop.swingx.JXLabel jXInfoLabel;
// End of variables declaration//GEN-END:variables

@Override
public void fireSelectionFinishedEvent(Point pStart, Point pEnd) {
addVillages(DataHolder.getSingleton().getVillagesInRegion(pStart, pEnd));
}

public void addVillages(List<Village> pVillages) {
/**
* Updates selection to given villages
* removes old selection
*
* @param pVillages the new selection
*/
public void updateSelection(List<Village> pVillages) {
boolean showBarbarian = GlobalOptions.getProperties().getBoolean("show.barbarian");
treeData.clear();
for (Village v : pVillages.toArray(new Village[]{})) {
Expand Down

This file was deleted.

0 comments on commit a09bab6

Please sign in to comment.