Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 14b2019

Browse files
Merge pull request #230 from oharaandrew314/v1.4
V1.4
2 parents 3c3bc97 + 13c2dcf commit 14b2019

34 files changed

+1227
-753
lines changed

Common

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,22 @@ The [Tinker Time Wiki](https://github.com/oharaandrew314/TinkerTime/wiki) contai
3232

3333
### Change Log
3434

35-
##### v2.0 (planned)
36-
37-
This major update is planned to feature a visual design overhaul, and .version file integration
35+
##### v1.4
36+
37+
###### New Features
38+
- You can now drag and drop URL icons from your browser and files into the mod list to add them
39+
- The Config Window has been visually updated
40+
- Task progress will now appear next to their respective mods as spinners
41+
- New mods will appear in the list as they are being added
42+
- The Lower Progress bars have been removed
43+
- The "Enter" and "Delete" keys will now toggle and delete mods in the list
44+
- Tooltips have been added to mods in the list, explaining their current state
45+
- The Mod Image View has been moved to the right panel
46+
- UserVoice support will be reitred. Support is now done through tinkertime at andrewohara dot io
47+
48+
###### Fixes
49+
- Pressing cancel while selecting a github asset will no longer delete the zip
50+
- Fix Regression where user would be asked to select github asset when they are just checking for updates
3851

3952
##### v1.3
4053

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ sourceSets {
1212

1313
main {
1414
java {
15-
srcDirs ('src', 'Common')
16-
exclude '**/test/**'
15+
srcDirs ('src', 'Common/src')
1716
}
1817
resources {
1918
srcDir 'res'
@@ -53,7 +52,7 @@ jar {
5352
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
5453

5554
manifest {
56-
attributes 'Main-Class': 'aohara.tinkertime.TinkerTime'
55+
attributes 'Main-Class': mainClassName
5756
}
5857
}
5958

res/icon/exampleModUrl.PNG

6.18 KB
Loading
Loading
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package aohara.tinkertime;
2+
3+
import java.awt.Component;
4+
import java.awt.datatransfer.DataFlavor;
5+
import java.awt.datatransfer.Transferable;
6+
import java.awt.datatransfer.UnsupportedFlavorException;
7+
import java.awt.dnd.DnDConstants;
8+
import java.awt.dnd.DropTarget;
9+
import java.awt.dnd.DropTargetDragEvent;
10+
import java.awt.dnd.DropTargetDropEvent;
11+
import java.awt.dnd.DropTargetEvent;
12+
import java.awt.dnd.DropTargetListener;
13+
import java.io.File;
14+
import java.io.IOException;
15+
import java.net.URL;
16+
import java.nio.file.Files;
17+
import java.util.Collection;
18+
19+
import aohara.common.views.Dialogs;
20+
import aohara.tinkertime.ModManager.ModUpdateFailedError;
21+
import aohara.tinkertime.crawlers.CrawlerFactory.UnsupportedHostException;
22+
23+
public class AddModDragDropHandler {
24+
25+
public AddModDragDropHandler(final Component listenTo, final ModManager modManager){
26+
new DropTarget(listenTo, new DropTargetListener(){
27+
28+
@Override
29+
public void dragEnter(DropTargetDragEvent dtde) {
30+
try {
31+
File file = getFile(dtde.getTransferable());
32+
if (isZip(file) || isUrl(file)){
33+
dtde.acceptDrag(DnDConstants.ACTION_LINK);
34+
} else {
35+
dtde.rejectDrag();
36+
}
37+
} catch (UnsupportedFlavorException | IOException e) {
38+
e.printStackTrace();
39+
dtde.rejectDrag();
40+
}
41+
listenTo.repaint();
42+
}
43+
44+
private File getFile(Transferable t) throws UnsupportedFlavorException, IOException{
45+
Object td = t.getTransferData(DataFlavor.javaFileListFlavor);
46+
if (td instanceof Collection){
47+
for (Object value : (Collection<?>) td){
48+
if (value instanceof File){
49+
return (File) value;
50+
}
51+
}
52+
}
53+
return null;
54+
}
55+
56+
private boolean isZip(File file){
57+
return file != null && file.getName().endsWith(".zip");
58+
}
59+
60+
private boolean isUrl(File file){
61+
return file != null && file.getName().endsWith(".url");
62+
}
63+
64+
private void handleUrlFile(File file){
65+
try {
66+
String contents = new String(Files.readAllBytes(file.toPath()));
67+
String url = contents.split("URL=")[1].split("]")[0];
68+
modManager.downloadMod(new URL(url));
69+
} catch (IOException | UnsupportedHostException | ModUpdateFailedError e) {
70+
Dialogs.errorDialog(listenTo, e);
71+
}
72+
}
73+
74+
private void handleZipFile(File file){
75+
modManager.addModZip(file.toPath());
76+
}
77+
78+
@Override
79+
public void dragOver(DropTargetDragEvent dtde) {
80+
// No Action
81+
}
82+
83+
@Override
84+
public void dropActionChanged(DropTargetDragEvent dtde) {
85+
// No Action
86+
}
87+
88+
@Override
89+
public void dragExit(DropTargetEvent dte) {
90+
// No Action
91+
}
92+
93+
@Override
94+
public void drop(DropTargetDropEvent dtde) {
95+
dtde.acceptDrop(DnDConstants.ACTION_COPY);
96+
try {
97+
File file = getFile(dtde.getTransferable());
98+
if (isZip(file)){
99+
handleZipFile(file);
100+
} else if (isUrl(file)){
101+
handleUrlFile(file);
102+
}
103+
} catch (UnsupportedFlavorException | IOException e) {
104+
Dialogs.errorDialog(listenTo, e);
105+
}
106+
}
107+
});
108+
}
109+
110+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package aohara.tinkertime;
2+
3+
import java.awt.event.KeyEvent;
4+
import java.awt.event.KeyListener;
5+
6+
import aohara.common.selectorPanel.SelectorListListener;
7+
import aohara.common.views.Dialogs;
8+
import aohara.tinkertime.ModManager.NoModSelectedException;
9+
import aohara.tinkertime.models.Mod;
10+
import aohara.tinkertime.views.TinkerDialogs;
11+
12+
class ModListListener implements KeyListener, SelectorListListener<Mod> {
13+
14+
private final ModManager mm;
15+
16+
ModListListener(ModManager mm){
17+
this.mm = mm;
18+
}
19+
20+
@Override
21+
public void keyPressed(KeyEvent e) {
22+
// Do Nothing
23+
}
24+
25+
@Override
26+
public void keyReleased(KeyEvent e) {
27+
// Do Nothing
28+
}
29+
30+
@Override
31+
public void keyTyped(KeyEvent evt) {
32+
try{
33+
switch(evt.getKeyChar()){
34+
case KeyEvent.VK_DELETE:
35+
Mod selectedMod = mm.getSelectedMod();
36+
if (TinkerDialogs.confirmDeleteMod(evt.getComponent(), selectedMod.name)){
37+
mm.deleteMod(selectedMod);
38+
}
39+
break;
40+
case KeyEvent.VK_ENTER:
41+
mm.toggleMod(mm.getSelectedMod());
42+
break;
43+
}
44+
} catch (NoModSelectedException ex){
45+
// Do nothing
46+
} catch(Exception ex){
47+
Dialogs.errorDialog(evt.getComponent(), ex);
48+
}
49+
}
50+
51+
@Override
52+
public void elementClicked(Mod mod, int numTimes) {
53+
if (numTimes == 2){
54+
mm.toggleMod(mod);
55+
}
56+
}
57+
58+
@Override
59+
public void elementSelected(Mod element) {
60+
mm.selectMod(element);
61+
}
62+
63+
}

0 commit comments

Comments
 (0)