mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Updates dmitool to be able to insert specific directions
Adds a direction option to the import command, that causes the imported icon state is overwrites the specified direction, if nodup is set. Otherwise, the direction is overwritten on a copy.
This commit is contained in:
Binary file not shown.
@@ -175,7 +175,7 @@ public class IconState {
|
|||||||
}
|
}
|
||||||
int pxW = in.imgInfo.cols;
|
int pxW = in.imgInfo.cols;
|
||||||
int pxH = in.imgInfo.rows;
|
int pxH = in.imgInfo.rows;
|
||||||
int frames = pxW / w;
|
int frames = pxW / w; //frames are read along the X axis, dirs along the Y, much like export.
|
||||||
int dirs = pxH / h;
|
int dirs = pxH / h;
|
||||||
|
|
||||||
// make sure the size is an integer multiple
|
// make sure the size is an integer multiple
|
||||||
@@ -211,6 +211,12 @@ public class IconState {
|
|||||||
return new IconState(name, dirs, frames, images, delays, rewind, loop, hotspot, movement);
|
return new IconState(name, dirs, frames, images, delays, rewind, loop, hotspot, movement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Converts a desired dir and frame to an index into the images array.
|
||||||
|
public int getIndex(int dir, int frame) {
|
||||||
|
return dir + frame*dirs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -244,6 +250,5 @@ public class IconState {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class Main {
|
|||||||
"\t movement | move | mov | m : [state] should be marked as a movement state\n" +
|
"\t movement | move | mov | m : [state] should be marked as a movement state\n" +
|
||||||
"\t delays L | delay L | del L | d L : use the list L as a comma-separated list of delays (e.g. '1,1,2,2,1')\n" +
|
"\t delays L | delay L | del L | d L : use the list L as a comma-separated list of delays (e.g. '1,1,2,2,1')\n" +
|
||||||
"\t hotspot H | hs H | h H : use H as the hotspot for this state\n" +
|
"\t hotspot H | hs H | h H : use H as the hotspot for this state\n" +
|
||||||
|
"\t direction D | dir D : replaces D with the image from [in], instead of the entire state. D can be 0-7 or S, N, E, etc. If the state does not already exist, this is ignored\n" +
|
||||||
"";
|
"";
|
||||||
|
|
||||||
public static void main(String[] args) throws FileNotFoundException, IOException, DMIException {
|
public static void main(String[] args) throws FileNotFoundException, IOException, DMIException {
|
||||||
@@ -270,6 +271,7 @@ public class Main {
|
|||||||
boolean movement = false;
|
boolean movement = false;
|
||||||
String hotspot = null;
|
String hotspot = null;
|
||||||
float[] delays = null;
|
float[] delays = null;
|
||||||
|
String replaceDir = null;
|
||||||
while(!argq.isEmpty()) {
|
while(!argq.isEmpty()) {
|
||||||
String s = argq.pollFirst();
|
String s = argq.pollFirst();
|
||||||
switch(s.toLowerCase()) {
|
switch(s.toLowerCase()) {
|
||||||
@@ -341,6 +343,15 @@ public class Main {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "dir":
|
||||||
|
case "direction":
|
||||||
|
if(!argq.isEmpty()) {
|
||||||
|
replaceDir = argq.pollFirst();
|
||||||
|
} else {
|
||||||
|
System.out.println("Argument '" + s + "' requires a direction argument following it!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Unknown import argument '" + s + "', ignoring.");
|
System.out.println("Unknown import argument '" + s + "', ignoring.");
|
||||||
break;
|
break;
|
||||||
@@ -352,6 +363,26 @@ public class Main {
|
|||||||
if(VERBOSITY >= 0) toImportTo.printInfo();
|
if(VERBOSITY >= 0) toImportTo.printInfo();
|
||||||
IconState is = IconState.importFromPNG(toImportTo, new FileInputStream(pngFile), stateName, delays, rewind, loop, hotspot, movement);
|
IconState is = IconState.importFromPNG(toImportTo, new FileInputStream(pngFile), stateName, delays, rewind, loop, hotspot, movement);
|
||||||
|
|
||||||
|
//If replaceDir is set, attempt to find an IconState with the same name.
|
||||||
|
//Then if nodup is set, replace the specified direction of that IconState with the (first direction) of the imported IconState.
|
||||||
|
//If nodup is not set, create a copy of the source IconState and apply the replace operation on that.
|
||||||
|
IconState targetIs;
|
||||||
|
if(replaceDir != null && (targetIs = toImportTo.getIconState(stateName)) != null) {
|
||||||
|
int dirToReplace = parseDir(replaceDir, targetIs);
|
||||||
|
int numFrames = is.frames < targetIs.frames? is.frames : targetIs.frames;
|
||||||
|
|
||||||
|
if(noDup) {
|
||||||
|
for(int frameIdx = 0; frameIdx < numFrames; frameIdx++) {
|
||||||
|
targetIs.images[targetIs.getIndex(dirToReplace, frameIdx)] = is.images[is.getIndex(0, frameIdx)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetIs = targetIs.clone();
|
||||||
|
for(int frameIdx = 0; frameIdx < numFrames; frameIdx++) {
|
||||||
|
targetIs.images[targetIs.getIndex(dirToReplace, frameIdx)] = is.images[is.getIndex(0, frameIdx)];
|
||||||
|
}
|
||||||
|
toImportTo.addIconState(null, targetIs);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if(noDup) {
|
if(noDup) {
|
||||||
if(!toImportTo.setIconState(is)) {
|
if(!toImportTo.setIconState(is)) {
|
||||||
toImportTo.addIconState(null, is);
|
toImportTo.addIconState(null, is);
|
||||||
@@ -359,6 +390,7 @@ public class Main {
|
|||||||
} else {
|
} else {
|
||||||
toImportTo.addIconState(null, is);
|
toImportTo.addIconState(null, is);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(VERBOSITY >= 0) toImportTo.printInfo();
|
if(VERBOSITY >= 0) toImportTo.printInfo();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user