Begin refactoring to use processing 2

This commit is contained in:
Sandy Noble 2013-09-01 18:25:33 +01:00
parent 51c34e65d2
commit f0a45e3a19
3 changed files with 19 additions and 19 deletions

View File

@ -446,11 +446,11 @@ void button_mode_selectPictureframe()
}
void button_mode_exportQueue()
{
exportQueueToFile();
selectOutput("Save queue as...", "exportQueueToFile"); // Opens file chooser
}
void button_mode_importQueue()
{
importQueueFromFile();
selectInput("Choose a file to import a queue from...", "importQueueFromFile");
}
void toggle_mode_drawDirect(boolean flag)
{

View File

@ -316,7 +316,6 @@ void submitDrawWindow(int theValue)
/*------------------------------------------------------------------------
Details about the "writing" subwindow
------------------------------------------------------------------------*/
String textToWrite = "";
String spriteFilePrefix = "sprite/let";
String spriteFileSuffix = ".txt";
@ -361,12 +360,12 @@ void spriteFilePrefixField(String value)
}
void textToWriteField(String value)
{
textToWrite = value;
textForVectorSprite = value;
}
String getTextToWrite()
{
return textToWrite;
return textForVectorSprite;
}
String getSpriteFilePrefix()
{
@ -379,7 +378,8 @@ String getSpriteFileSuffix()
void importTextButton()
{
textToWrite = importTextToWriteFromFile();
// This loads the file contents into the variable called textForVectorSprite
selectInput("Choose a text file to load from...", "importTextToWriteFromFile");
Textfield tf = (Textfield) cp5.controller("textToWriteField");
tf.setText(getTextToWrite());
tf.submit();

View File

@ -504,6 +504,9 @@ String shapeSaveExtension = ".svg";
//PImage dpadXImage = null;
//PImage dpadYImage = null;
// The block of text imported from file, used for the vector sprite writing
String textForVectorSprite = "";
void setup()
{
println("Running polargraph controller");
@ -1819,12 +1822,11 @@ void sizeImageToFitBox()
getDisplayMachine().setImageFrame(r);
}
void exportQueueToFile()
void exportQueueToFile(File selectedFile)
{
if (!commandQueue.isEmpty() || !realtimeCommandQueue.isEmpty())
{
String savePath = selectOutput(); // Opens file chooser
if (savePath == null)
if (selectedFile == null)
{
// If a file was not selected
println("No output file was selected...");
@ -1832,38 +1834,36 @@ void exportQueueToFile()
else
{
// If a file was selected, print path to folder
println("Output file: " + savePath);
println("Output file: " + selectedFile);
List<String> allCommands = new ArrayList<String>(realtimeCommandQueue);
allCommands.addAll(commandQueue);
String[] list = (String[]) allCommands.toArray(new String[0]);
saveStrings(savePath, list);
saveStrings(selectedFile, list);
println("Completed queue export, " + list.length + " commands exported.");
}
}
}
void importQueueFromFile()
void importQueueFromFile(File selectedFile)
{
commandQueue.clear();
String loadPath = selectInput();
if (loadPath == null)
if (selectedFile == null)
{
// nothing selected
println("No input file was selected.");
}
else
{
println("Input file: " + loadPath);
String commands[] = loadStrings(loadPath);
println("Input file: " + selectedFile);
String commands[] = loadStrings(selectedFile);
// List<String> list = Arrays
commandQueue.addAll(Arrays.asList(commands));
println("Completed queue import, " + commandQueue.size() + " commands found.");
}
}
String importTextToWriteFromFile()
void importTextToWriteFromFile(File loadPath)
{
String loadPath = selectInput();
String result = "";
if (loadPath == null)
{
@ -1882,8 +1882,8 @@ String importTextToWriteFromFile()
result = sb.toString();
println("Completed text import, " + result.length() + " characters found.");
textForVectorSprite = result;
}
return result;
}