Last active
October 9, 2015 03:59
-
-
Save hadidjah/93f5ead139e2ee335b70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Work-in-progress, all this runs right now is a UI window | |
/*MapSave v 1.0, 03.21.2015 | |
Hadidjah Chamberlin | |
Contact: hadidjah.com / hadidjah@gmail.com | |
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. | |
Good luck, have fun! | |
*/ | |
// Only run in Photoshop | |
#target photoshop | |
//warn if no documents are open | |
if (documents.length == 0) | |
{ | |
alert("No documents are open! Please open your master texture file and run again!", "No File Found"); | |
} | |
const kMyFlag = app.stringIDToTypeID( "myFlag" ); | |
const kMyNumber = app.stringIDToTypeID( "myNumber" ); | |
const kMySettings = "mySettings"; | |
function saveSettings() | |
{ | |
var desc = new ActionDescriptor(); | |
desc.putBoolean(kMyFlag, true); | |
desc.putInteger(kMyNumber, 42); | |
// "true" means setting persists across Photoshop launches. | |
app.putCustomOptions( kMySettings, desc, true ); | |
} | |
function getSettings() | |
{ | |
var desc = app.getCustomOptions( kMySettings ); | |
return [desc.getBoolean( kMyFlag ), desc.getInteger( kMyNumber )]; | |
} | |
//Persistent Variables | |
var suffixName; | |
var suffixPartial; | |
var suffixInitial; | |
var suffixDota; | |
var suffixColor; | |
var alphainColor; | |
var suffixNormal; | |
var alphaInNormal; | |
var suffixSpec; | |
var greypackSpecGlossGlow; | |
var specAsNormAlpha; | |
var suffixGloss; | |
var glossAsSpecAlpha; | |
var suffixGlow; | |
var suffixDota1; | |
var suffixDota2; | |
// | |
var groupCount = app.activeDocument.layerSets.length; | |
//Define naming vars | |
var saveLocation = app.activeDocument.path; | |
/*if (app.activeDocument.path) | |
{ | |
saveLocation = app.activeDocument.path; | |
} else { | |
saveLocation = "Choose a save location"; | |
}*/ | |
var docName = app.activeDocument.name; | |
var prefixName; | |
//Resize variables | |
var docW = app.activeDocument.width; | |
var docH = app.activeDocument.height; | |
var inputPercent = 50; | |
var resizePercent = (inputPercent * 0.1); | |
var resizeW = (app.activeDocument.width * resizePercent); | |
var resizeH = (app.activeDocument.height * resizePercent); | |
var sharpenAmount = 25; | |
var sharpenRadius = 1; | |
var sharpenThreshhold = 0; | |
//Check if canvas size is power of two | |
if ((docW != 4 && docW != 8 && docW != 16 && docW != 32 && docW != 64 && docW != 128 && docW != 256 && docW != 512 && docW != 1024 && docW != 2048) || (docH != 4 && docH != 8 && docH != 16 && docH != 32 && docH != 64 && docH != 128 && docH != 256 && docH != 512 && docH != 1024 && docH != 2048)) | |
{ | |
var badFrameSize = true; | |
} else { | |
var badFrameSize = false; | |
} | |
//BUILD THE WINDOW | |
var dlg = new Window('dialog', 'Texture Map Compiler',undefined); | |
dlg.orientation = 'column'; | |
dlg.alignChildren = 'center'; | |
dlg.preferredSize = [800, 600]; | |
dlg.top = dlg.add('group', undefined); | |
//TOP sections | |
dlg.top.alignChildren = 'top'; | |
dlg.top.orientation = 'row'; | |
//Offer to SAVE PREFERENCES for future reference | |
dlg.top.prefs = dlg.top.add('panel', undefined, 'Select or Save Preferences'); | |
dlg.top.prefs.alignChildren = 'left'; | |
dlg.top.prefs.selectPrefs = dlg.top.prefs.add('dropdownlist', undefined, 'Select Existing Presets'); | |
dlg.top.prefs.savePrefs = dlg.top.prefs.add('checkbox', undefined, 'Do you want to save your preferences for future sessions?'); | |
dlg.top.prefs.presetName = dlg.top.prefs.add('edittext', undefined, 'Name New Preset'); | |
//FILENAME PREFIX PANEL | |
dlg.top.prefixPanel = dlg.top.add('panel', undefined, 'Select a prefix for your texture names:'); | |
dlg.top.prefixPanel.alignChildren = 'left'; | |
dlg.top.prefixPanel.orientation = 'column'; | |
//save target | |
dlg.top.prefixPanel.saveTarget = dlg.top.prefixPanel.add('group', undefined) | |
dlg.top.prefixPanel.saveTarget.orientation = 'row'; | |
dlg.top.prefixPanel.saveTarget.instructions = dlg.top.prefixPanel.saveTarget.add('statictext', undefined, "Save textures to:", {multiline: false}); | |
dlg.top.prefixPanel.saveTarget.folderPath = dlg.top.prefixPanel.saveTarget.add('editText', undefined, saveLocation, {multiline: false}); | |
dlg.top.prefixPanel.saveTarget.folderPath.characters = 64; | |
//use filename | |
dlg.top.prefixPanel.current = dlg.top.prefixPanel.add('group', undefined); | |
dlg.top.prefixPanel.current.orientation = 'row'; | |
dlg.top.prefixPanel.custom = dlg.top.prefixPanel.add('group', undefined); | |
dlg.top.prefixPanel.custom.orientation = 'row'; | |
dlg.top.prefixPanel.custom.newPrefixText = dlg.top.prefixPanel.custom.add('statictext', undefined, 'Enter a new prefix: ', {multiline: false}); | |
dlg.top.prefixPanel.custom.newPrefix = dlg.top.prefixPanel.custom.add('edittext', undefined, docName, {multiline: false}); | |
dlg.top.prefixPanel.custom.newPrefix.characters = 64; | |
//SUFFIXES AND SELECT TEXTURE TYPES | |
dlg.texturePanel = dlg.add('group', undefined); | |
dlg.texturePanel.alignChildren = 'top'; | |
dlg.texturePanel.orientation = 'row'; | |
dlg.texturePanel.suffixPanel = dlg.texturePanel.add('panel', undefined, 'Select a suffix for your texture names:'); | |
dlg.texturePanel.suffixPanel.orientation = 'row'; | |
//PRESETS | |
dlg.texturePanel.suffixPanel.presets = dlg.texturePanel.suffixPanel.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.alignChildren = 'left'; | |
dlg.texturePanel.suffixPanel.presets.orientation = 'column'; | |
dlg.texturePanel.suffixPanel.presets.dropDown = dlg.texturePanel.suffixPanel.presets.add('dropdownlist', undefined, 'Select a suffix for your textures:'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.alignment = 'center'; | |
dlg.texturePanel.suffixPanel.presets.dropDown.instructions = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Select a set of suffix presets:'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.partial = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Use partial texture names as suffixes'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.full = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Use texture names as suffixes'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.groups = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Use layer group names as suffixes'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.initials = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Use layer group names as suffixes'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.dota = dlg.texturePanel.suffixPanel.presets.dropDown.add('item', 'Use DotA Workshop suffixes'); | |
dlg.texturePanel.suffixPanel.presets.dropDown.selection = dlg.texturePanel.suffixPanel.presets.dropDown.instructions; | |
dlg.texturePanel.suffixPanel.presets.instructions = dlg.texturePanel.suffixPanel.presets.add('statictext', undefined, '(You can edit individual suffixes below:)'); | |
dlg.texturePanel.suffixPanel.presets.instructions.alignment = 'center'; | |
//color | |
dlg.texturePanel.suffixPanel.presets.color = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.color.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.color.checkbox = dlg.texturePanel.suffixPanel.presets.color.add('checkbox', undefined, "Color/Diffuse suffix:"); | |
dlg.texturePanel.suffixPanel.presets.color.checkbox .value = true; | |
dlg.texturePanel.suffixPanel.presets.color.suffix = dlg.texturePanel.suffixPanel.presets.color.add('edittext', undefined, "_color", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.color.suffix.characters = 16; | |
dlg.texturePanel.suffixPanel.presets.colorAlpha = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.colorAlpha.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.colorAlpha.checkbox = dlg.texturePanel.suffixPanel.presets.colorAlpha.add('checkbox', undefined, "Color/Diffuse Alpha:"); | |
dlg.texturePanel.suffixPanel.presets.colorAlpha.checkbox .value = true; | |
dlg.texturePanel.suffixPanel.presets.colorAlpha.folder = dlg.texturePanel.suffixPanel.presets.colorAlpha.add('edittext', undefined, "Folder name", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.colorAlpha.folder.characters = 16; | |
//normal | |
dlg.texturePanel.suffixPanel.presets.normal = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.normal.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.normal.checkbox = dlg.texturePanel.suffixPanel.presets.normal.add('checkbox', undefined, "Normal suffix:"); | |
dlg.texturePanel.suffixPanel.presets.normal.checkbox.value = true; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix = dlg.texturePanel.suffixPanel.presets.normal.add('edittext', undefined, "_normal", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.characters = 16; | |
//specular | |
dlg.texturePanel.suffixPanel.presets.specular = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.specular.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.specular.checkbox = dlg.texturePanel.suffixPanel.presets.specular.add('checkbox', undefined, "Specular suffix:"); | |
dlg.texturePanel.suffixPanel.presets.specular.checkbox.value = true; | |
dlg.texturePanel.suffixPanel.presets.specular.suffix = dlg.texturePanel.suffixPanel.presets.specular.add('edittext', undefined, "_spec", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.specular.suffix.characters = 16; | |
dlg.texturePanel.suffixPanel.presets.specAsAlpha = dlg.texturePanel.suffixPanel.presets.add('checkbox', undefined, 'Spec as alpha in normal?'); | |
dlg.texturePanel.suffixPanel.presets.specAsAlpha = false; | |
//gloss | |
dlg.texturePanel.suffixPanel.presets.gloss = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.gloss.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.gloss.checkbox = dlg.texturePanel.suffixPanel.presets.gloss.add('checkbox', undefined, "Gloss suffix:"); | |
dlg.texturePanel.suffixPanel.presets.gloss.checkbox.value = true; | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix = dlg.texturePanel.suffixPanel.presets.gloss.add('edittext', undefined, "_gloss", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix.characters = 16; | |
dlg.texturePanel.suffixPanel.presets.glossAsAlpha = dlg.texturePanel.suffixPanel.presets.add('checkbox', undefined, 'Gloss as alpha in specular map?'); | |
dlg.texturePanel.suffixPanel.presets.glossAsAlpha.value = true; | |
//glow | |
dlg.texturePanel.suffixPanel.presets.glow = dlg.texturePanel.suffixPanel.presets.add('group', undefined); | |
dlg.texturePanel.suffixPanel.presets.glow.orientation = 'row'; | |
dlg.texturePanel.suffixPanel.presets.glow.checkbox = dlg.texturePanel.suffixPanel.presets.glow.add('checkbox', undefined, "Glow/Emissive suffix:"); | |
dlg.texturePanel.suffixPanel.presets.glow.checkbox.value = true; | |
dlg.texturePanel.suffixPanel.presets.glow.suffix = dlg.texturePanel.suffixPanel.presets.glow.add('edittext', undefined, "_glow", {multiline: false}); | |
dlg.texturePanel.suffixPanel.presets.glow.suffix.characters = 16; | |
//onChange instructions for suffix drop-down | |
dlg.texturePanel.suffixPanel.presets.dropDown.onChange = function () { | |
if (dlg.texturePanel.suffixPanel.presets.dropDown.selection != null) { | |
if (this.selection.partial) { | |
dlg.texturePanel.suffixPanel.presets.color.suffix.text = "_col"; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.text = "_norm"; | |
dlg.texturePanel.suffixPanel.presets.specular.suffix.text = "_spec"; | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix.text = "_gloss"; | |
dlg.texturePanel.suffixPanel.presets.glow.suffix.text = "_glow"; | |
} | |
else if (this.selection.initial) { | |
dlg.texturePanel.suffixPanel.presets.color.suffix.text = "_c"; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.text = "_n"; | |
dlg.texturePanel.suffixPanel.presets.specular.suffix.text = "_s"; | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix.text = "_g"; | |
dlg.texturePanel.suffixPanel.presets.glow.suffix.text = "_e"; | |
} | |
else if (this.selection.full) { | |
dlg.texturePanel.suffixPanel.presets.color.suffix.text = "_color"; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.text = "_normal"; | |
dlg.texturePanel.suffixPanel.presets.specular.suffix.text = "_specular"; | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix.text = "_gloss"; | |
dlg.texturePanel.suffixPanel.presets.glow.suffix.text = "_glow"; | |
} | |
else if (this.selection.groups) { | |
dlg.texturePanel.suffixPanel.presets.color.suffix.text = "_col"; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.text = "_norm"; | |
dlg.texturePanel.suffixPanel.presets.specular.suffix.text = "_spec"; | |
dlg.texturePanel.suffixPanel.presets.gloss.suffix.text = "_gloss"; | |
dlg.texturePanel.suffixPanel.presets.glow.suffix.text = "_glow"; | |
} | |
else if (this.selection.dota) { | |
dlg.texturePanel.suffixPanel.presets.color.suffix.text = "_color"; | |
dlg.texturePanel.suffixPanel.presets.normal.suffix.text = "_normal"; | |
//create _mask1 | |
//create _mask2 | |
} | |
} | |
} | |
//CUSTOM GREYPACKS | |
dlg.texturePanel.custom = dlg.texturePanel.add ('panel', undefined, "Create custom greypacks:"); | |
dlg.texturePanel.custom.orientation = 'column'; | |
//gp1 | |
dlg.texturePanel.custom.gp1 = dlg.texturePanel.custom.add('group', undefined); | |
dlg.texturePanel.custom.gp1.orientation = 'column'; | |
dlg.texturePanel.custom.gp1.checkbox = dlg.texturePanel.custom.gp1.add('group', undefined); | |
dlg.texturePanel.custom.gp1.checkbox.orientation = 'row'; | |
dlg.texturePanel.custom.gp1.checkbox.checkbox = dlg.texturePanel.custom.gp1.add('checkbox', undefined, "New greypack texture:"); | |
dlg.texturePanel.custom.gp1.checkbox.checkbox.value = true; | |
dlg.texturePanel.custom.gp1.suffix = dlg.texturePanel.custom.gp1.add('edittext', undefined, "_gp1", {multiline: false}); | |
dlg.texturePanel.custom.gp1.suffix.characters = 16; | |
//dlg.textuerPanel.custom.gp1.suffix.visible = false; | |
//onto the new sorty groups! | |
dlg.texturePanel.custom.gp1.settings = dlg.texturePanel.custom.gp1.add ('group', undefined); | |
dlg.texturePanel.custom.gp1.settings.orientation = 'column'; | |
//Red | |
dlg.texturePanel.custom.gp1.settings.redChannel = dlg.texturePanel.custom.gp1.settings.add('group', undefined); | |
dlg.texturePanel.custom.gp1.settings.redChannel.checkboxR = dlg.texturePanel.custom.gp1.settings.redChannel.add('checkbox', undefined, "Folder name for Red channel:"); | |
dlg.texturePanel.custom.gp1.settings.redChannel.checkboxR.value = true; | |
dlg.texturePanel.custom.gp1.settings.redChannel.redFolder = dlg.texturePanel.custom.gp1.settings.redChannel.add('edittext', undefined, "GP1_Red", {multiline: false}); | |
dlg.texturePanel.custom.gp1.settings.redChannel.redFolder.characters = 16; | |
//Green | |
dlg.texturePanel.custom.gp1.settings.greenChannel = dlg.texturePanel.custom.gp1.settings.add('group', undefined); | |
dlg.texturePanel.custom.gp1.settings.greenChannel.checkboxG = dlg.texturePanel.custom.gp1.settings.greenChannel.add('checkbox', undefined, "Folder name for Green channel:"); | |
dlg.texturePanel.custom.gp1.settings.greenChannel.checkboxG.value = true; | |
dlg.texturePanel.custom.gp1.settings.greenChannel.greenFolder = dlg.texturePanel.custom.gp1.settings.greenChannel.add('edittext', undefined, "GP1_Green", {multiline: false}); | |
dlg.texturePanel.custom.gp1.settings.greenChannel.greenFolder.characters = 16; | |
//Blue | |
dlg.texturePanel.custom.gp1.settings.blueChannel = dlg.texturePanel.custom.gp1.settings.add('group', undefined); | |
dlg.texturePanel.custom.gp1.settings.blueChannel.checkboxB = dlg.texturePanel.custom.gp1.settings.blueChannel.add('checkbox', undefined, "Folder name for Blue channel:"); | |
dlg.texturePanel.custom.gp1.settings.blueChannel.checkboxB.value = true; | |
dlg.texturePanel.custom.gp1.settings.blueChannel.blueFolder = dlg.texturePanel.custom.gp1.settings.blueChannel.add('edittext', undefined, "GP1_Blue", {multiline: false}); | |
dlg.texturePanel.custom.gp1.settings.blueChannel.blueFolder.characters = 16; | |
//Alpha | |
dlg.texturePanel.custom.gp1.settings.alphaChannel = dlg.texturePanel.custom.gp1.settings.add('group', undefined); | |
dlg.texturePanel.custom.gp1.settings.alphaChannel.checkboxA = dlg.texturePanel.custom.gp1.settings.alphaChannel.add('checkbox', undefined, "Folder name for Alpha channel:"); | |
dlg.texturePanel.custom.gp1.settings.alphaChannel.checkboxA.value = false; | |
dlg.texturePanel.custom.gp1.settings.alphaChannel.alphaFolder = dlg.texturePanel.custom.gp1.settings.alphaChannel.add('edittext', undefined, "GP1_Alpha", {multiline: false}); | |
dlg.texturePanel.custom.gp1.settings.alphaChannel.alphaFolder.characters = 16; | |
//add option for another greypack | |
dlg.texturePanel.custom.gp2 = dlg.texturePanel.custom.add('group', undefined); | |
dlg.texturePanel.custom.gp2.orientation = 'column'; | |
dlg.texturePanel.custom.gp2.checkbox = dlg.texturePanel.custom.gp2.add('group', undefined); | |
dlg.texturePanel.custom.gp2.checkbox.orientation = 'column'; | |
dlg.texturePanel.custom.gp2.checkbox.checkbox = dlg.texturePanel.custom.gp2.add('checkbox', undefined, "Create custom greypack:"); | |
dlg.texturePanel.custom.gp2.checkbox.checkbox.value = false; | |
//---POP CUSTOM GREYPACK MENUS IN AND OUT | |
dlg.texturePanel.custom.gp1.checkbox.checkbox.onChange = function() { | |
if (dlg.texturePanel.custom.gp1.checkbox.checkbox.value == true){ | |
dlg.texturePanel.custom.gp1.checkbox.checkbox.value = false; | |
} else { | |
dlg.texturePanel.custom.gp1.checkbox.checkbox.value = true; | |
//tack filename suffix to the end of the checkbox | |
} | |
} | |
//Build the FRAME WARNING if the size of the frames is not a power of two | |
if (badFrameSize) | |
{ | |
dlg.sizeWarningPanel = dlg.add('panel', undefined, 'WARNING'); | |
dlg.sizeWarningPanel.bodyText = dlg.sizeWarningPanel.add('statictext', undefined, "Your frame texture are not a power of two. This can negatively impact mipping and performance.", {multiline: false}); | |
dlg.sizeWarningPanel.bodyText = dlg.sizeWarningPanel.add('statictext', undefined, "Consider resizing your texture dimensions to powers of two, such as 64, 128, 256, etc.", {multiline: false}); | |
} | |
//RESIZE AND SHARPEN | |
dlg.resizePanel = dlg.add('panel', undefined, 'Resize and Sharpen'); | |
dlg.resizePanel.alignChildren = 'left'; | |
dlg.resizePanel.orientation = 'column'; | |
//resize | |
dlg.resizePanel.resize = dlg.resizePanel.add('group', undefined); | |
dlg.resizePanel.resize.orientation = 'row'; | |
dlg.resizePanel.resize.checkbox = dlg.resizePanel.resize.add('checkbox', undefined, 'Resize Textures?:'); | |
dlg.resizePanel.resize.checkbox.value = true; | |
dlg.resizePanel.resize.dropdown = dlg.resizePanel.resize.add('dropdownlist', undefined, 'Enter new height and width:'); | |
dlg.resizePanel.resize.dropdown.percent = dlg.resizePanel.resize.dropdown.add('item', undefined, 'Resize by percentage:'); | |
dlg.resizePanel.resize.dropdown.hw = dlg.resizePanel.resize.dropdown.add('item', undefined, 'Enter new height and width:'); | |
dlg.resizePanel.resize.dropdown.selection = dlg.resizePanel.resize.dropdown.percent; | |
//percent | |
dlg.resizePanel.resize.percent = dlg.resizePanel.resize.add('edittext', undefined, inputPercent, {multiline: false}); | |
dlg.resizePanel.resize.percent.characters = 3; | |
dlg.resizePanel.resize.percentSign = dlg.resizePanel.resize.add('statictext', undefined, "%", {multiline: false}); | |
//sharpen | |
dlg.resizePanel.sharpen = dlg.resizePanel.add('group', undefined); | |
dlg.resizePanel.sharpen.orientation = 'row'; | |
dlg.resizePanel.sharpen.checkbox = dlg.resizePanel.sharpen.add('checkbox', undefined, 'Run Unsharp Mask?:'); | |
dlg.resizePanel.sharpen.checkbox.value = true; | |
dlg.resizePanel.sharpen.amountTitle = dlg.resizePanel.sharpen.add('statictext', undefined, "Amount:", {multiline: false}); | |
dlg.resizePanel.sharpen.amount = dlg.resizePanel.sharpen.add('edittext', undefined, sharpenAmount, {multiline: false}); | |
dlg.resizePanel.sharpen.radiusTitle = dlg.resizePanel.sharpen.add('statictext', undefined, "Radius:", {multiline: false}); | |
dlg.resizePanel.sharpen.radius = dlg.resizePanel.sharpen.add('edittext', undefined, sharpenRadius, {multiline: false}); | |
dlg.resizePanel.sharpen.threshholdTitle = dlg.resizePanel.sharpen.add('statictext', undefined, "Threshhold:", {multiline: false}); | |
dlg.resizePanel.sharpen.threshhold = dlg.resizePanel.sharpen.add('edittext', undefined, sharpenThreshhold, {multiline: false}); | |
//Build the BUTTON PANEL for running things | |
dlg.buttonPanel = dlg.add('group', undefined); | |
dlg.buttonPanel.orientation = 'row'; | |
//run script button | |
dlg.buttonPanel.applyButton = dlg.buttonPanel.add('button', undefined, 'Save Textures', {name:'ok'}); | |
dlg.buttonPanel.applyButton.preferredSize = [200, 24]; | |
//cancel button | |
dlg.buttonPanel.cancelButton = dlg.buttonPanel.add('button', undefined, 'Exit Script', {name:'cancel'}); | |
dlg.buttonPanel.cancelButton.preferredSize = [120, 24]; | |
//----ONCHANGE info----- | |
dlg.resizePanel.resize.checkbox.onClick = function() { | |
if (dlg.resizePanel.resize.checkbox.value == true) | |
{ | |
dlg.resizePanel.resize.checkbox.value = false; | |
} | |
if (dlg.resizePanel.resize.checkbox.value == false) | |
{ | |
dlg.resizePanel.resize.checkbox.value = true; | |
} | |
} | |
dlg.resizePanel.sharpen.checkbox.onClick = function() { | |
if (dlg.resizePanel.sharpen.checkbox.value == true) | |
{ | |
dlg.resizePanel.sharpen.checkbox.value = false; | |
} | |
if (dlg.resizePanel.sharpen.checkbox.value == false) | |
{ | |
dlg.resizePanel.sharpen.checkbox.value = true; | |
} | |
} | |
//Button management | |
//CLOSE on button press | |
dlg.buttonPanel.cancelButton = function() { | |
return dlg.close(); | |
}; | |
//RUN on button press | |
dlg.buttonPanel.applyButton.onClick = function() | |
{ | |
//SET ALL THE VARIABLES | |
var newSaveLocation = dlg.top.prefixPanel.saveTarget.folderPath; | |
var filePrefix = dlg.top.prefixPanel.custom.newPrefix.text; | |
var colorSuffix = dlg.texturePanel.suffixPanel.presets.color.suffix.text; | |
var normalSuffix = dlg.texturePanel.suffixPanel.presets.normal.suffix.text; | |
var specSuffix = dlg.texturePanel.suffixPanel.presets.specular.suffix.text; | |
//RESIZE IMAGE | |
if (dlg.resizePanel.resize.checkbox.value == true) | |
{ | |
app.activeDocument.resizeImage (UnitValue(docW,'px'), UnitValue(docH,'px')); | |
} | |
//Unsharpk mask | |
if (dlg.resizePanel.sharpen.checkbox.value == true) | |
{ | |
activeDocument.activeLayer.applyUnSharpMask(sharpenAmount,sharpenRadius,sharpenThreshhold); | |
} | |
/* | |
if (dlg.textureSelectPanel.saveNormal.value == true) | |
{ | |
if (app.activeDocument.layerSets.name == suffixNormal || app.activeDocument.layerSets.name == "normal" || app.activeDocument.layerSets.name == "n" || app.activeDocument.layerSets.name == "norm" || app.activeDocument.layerSets.name == "tangent") | |
{ | |
} | |
else { | |
alert ("Cannot find normal map group.", "Error"); | |
} | |
} | |
} | |
if (dlg.textureSelectPanel.saveNormal.value == true) | |
{ | |
// n, normal, norm | |
} | |
} | |
//Resize canvas to fit all the tiles | |
app.activeDocument.resizeCanvas((cellW*columnCount), (cellH*rowCount), AnchorPosition.TOPLEFT); | |
//TURN INTO GROUP CYCLER | |
while (layersMoved < layerCount-1) | |
{ | |
//Move frame layer | |
while ((currentRow < rowCount) && (layersMoved < layerCount)) | |
{ | |
currentLayer.translate((cellW*currentColumn), (cellH*currentRow)); | |
currentColumn += 1; | |
currentLayerPlaceholder -= 1; | |
if (currentLayerPlaceholder < 0) | |
{ | |
currentLayerPlaceholder = 0; | |
} | |
currentLayer = app.activeDocument.layers[currentLayerPlaceholder]; | |
layersMoved++; | |
//Update current row and column as needed | |
if (currentColumn == columnCount) | |
{ | |
currentRow += 1; | |
currentColumn = 0; | |
} | |
} | |
} | |
*/ | |
var saveColorFile = new File(saveLocation+'/'+filePrefix+colorSuffix+ '.jpg'); | |
var saveNormalFile = new File(saveLocation+'/'+filePrefix+normalSuffix+ '.jpg'); | |
var saveSpecFile = new File(saveLocation+'/'+filePrefix+specSuffix+ '.jpg'); | |
jpgSaveOptions = new JPEGSaveOptions(); | |
jpgSaveOptions.embedColorProfile = true; | |
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; | |
jpgSaveOptions.matte = MatteType.NONE; | |
jpgSaveOptions.quality = 12; | |
// if (dlg.texturePanel.suffixPanel.presets.color.checkbox.value == true) | |
// { | |
app.activeDocument.saveAs(saveColorFile, jpgSaveOptions, true,Extension.LOWERCASE); | |
// } | |
// if (dlg.texturePanel.suffixPanel.presets.normal.checkbox.value == true) | |
// { | |
app.activeDocument.saveAs(saveNormalFile, jpgSaveOptions, true,Extension.LOWERCASE); | |
// } | |
// if (dlg.texturePanel.suffixPanel.presets.specular.checkbox.value == true) | |
// { | |
app.activeDocument.saveAs(saveSpecFile, jpgSaveOptions, true,Extension.LOWERCASE); | |
// } | |
dlg.close(); | |
} | |
//Moooom, are we building yet? | |
dlg.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment