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

Commit

Permalink
Merge pull request #230 from oharaandrew314/v1.4
Browse files Browse the repository at this point in the history
V1.4
  • Loading branch information
oharaandrew314 committed Apr 28, 2015
2 parents 3c3bc97 + 13c2dcf commit 14b2019
Show file tree
Hide file tree
Showing 34 changed files with 1,227 additions and 753 deletions.
2 changes: 1 addition & 1 deletion Common
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,22 @@ The [Tinker Time Wiki](https://github.com/oharaandrew314/TinkerTime/wiki) contai

### Change Log

##### v2.0 (planned)

This major update is planned to feature a visual design overhaul, and .version file integration
##### v1.4

###### New Features
- You can now drag and drop URL icons from your browser and files into the mod list to add them
- The Config Window has been visually updated
- Task progress will now appear next to their respective mods as spinners
- New mods will appear in the list as they are being added
- The Lower Progress bars have been removed
- The "Enter" and "Delete" keys will now toggle and delete mods in the list
- Tooltips have been added to mods in the list, explaining their current state
- The Mod Image View has been moved to the right panel
- UserVoice support will be reitred. Support is now done through tinkertime at andrewohara dot io

###### Fixes
- Pressing cancel while selecting a github asset will no longer delete the zip
- Fix Regression where user would be asked to select github asset when they are just checking for updates

##### v1.3

Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ sourceSets {

main {
java {
srcDirs ('src', 'Common')
exclude '**/test/**'
srcDirs ('src', 'Common/src')
}
resources {
srcDir 'res'
Expand Down Expand Up @@ -53,7 +52,7 @@ jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

manifest {
attributes 'Main-Class': 'aohara.tinkertime.TinkerTime'
attributes 'Main-Class': mainClassName
}
}

Expand Down
Binary file added res/icon/exampleModUrl.PNG
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.
110 changes: 110 additions & 0 deletions src/aohara/tinkertime/AddModDragDropHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package aohara.tinkertime;

import java.awt.Component;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.util.Collection;

import aohara.common.views.Dialogs;
import aohara.tinkertime.ModManager.ModUpdateFailedError;
import aohara.tinkertime.crawlers.CrawlerFactory.UnsupportedHostException;

public class AddModDragDropHandler {

public AddModDragDropHandler(final Component listenTo, final ModManager modManager){
new DropTarget(listenTo, new DropTargetListener(){

@Override
public void dragEnter(DropTargetDragEvent dtde) {
try {
File file = getFile(dtde.getTransferable());
if (isZip(file) || isUrl(file)){
dtde.acceptDrag(DnDConstants.ACTION_LINK);
} else {
dtde.rejectDrag();
}
} catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();
dtde.rejectDrag();
}
listenTo.repaint();
}

private File getFile(Transferable t) throws UnsupportedFlavorException, IOException{
Object td = t.getTransferData(DataFlavor.javaFileListFlavor);
if (td instanceof Collection){
for (Object value : (Collection<?>) td){
if (value instanceof File){
return (File) value;
}
}
}
return null;
}

private boolean isZip(File file){
return file != null && file.getName().endsWith(".zip");
}

private boolean isUrl(File file){
return file != null && file.getName().endsWith(".url");
}

private void handleUrlFile(File file){
try {
String contents = new String(Files.readAllBytes(file.toPath()));
String url = contents.split("URL=")[1].split("]")[0];
modManager.downloadMod(new URL(url));
} catch (IOException | UnsupportedHostException | ModUpdateFailedError e) {
Dialogs.errorDialog(listenTo, e);
}
}

private void handleZipFile(File file){
modManager.addModZip(file.toPath());
}

@Override
public void dragOver(DropTargetDragEvent dtde) {
// No Action
}

@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
// No Action
}

@Override
public void dragExit(DropTargetEvent dte) {
// No Action
}

@Override
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
try {
File file = getFile(dtde.getTransferable());
if (isZip(file)){
handleZipFile(file);
} else if (isUrl(file)){
handleUrlFile(file);
}
} catch (UnsupportedFlavorException | IOException e) {
Dialogs.errorDialog(listenTo, e);
}
}
});
}

}
63 changes: 63 additions & 0 deletions src/aohara/tinkertime/ModListListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package aohara.tinkertime;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import aohara.common.selectorPanel.SelectorListListener;
import aohara.common.views.Dialogs;
import aohara.tinkertime.ModManager.NoModSelectedException;
import aohara.tinkertime.models.Mod;
import aohara.tinkertime.views.TinkerDialogs;

class ModListListener implements KeyListener, SelectorListListener<Mod> {

private final ModManager mm;

ModListListener(ModManager mm){
this.mm = mm;
}

@Override
public void keyPressed(KeyEvent e) {
// Do Nothing
}

@Override
public void keyReleased(KeyEvent e) {
// Do Nothing
}

@Override
public void keyTyped(KeyEvent evt) {
try{
switch(evt.getKeyChar()){
case KeyEvent.VK_DELETE:
Mod selectedMod = mm.getSelectedMod();
if (TinkerDialogs.confirmDeleteMod(evt.getComponent(), selectedMod.name)){
mm.deleteMod(selectedMod);
}
break;
case KeyEvent.VK_ENTER:
mm.toggleMod(mm.getSelectedMod());
break;
}
} catch (NoModSelectedException ex){
// Do nothing
} catch(Exception ex){
Dialogs.errorDialog(evt.getComponent(), ex);
}
}

@Override
public void elementClicked(Mod mod, int numTimes) {
if (numTimes == 2){
mm.toggleMod(mod);
}
}

@Override
public void elementSelected(Mod element) {
mm.selectMod(element);
}

}
Loading

0 comments on commit 14b2019

Please sign in to comment.