So I want to know if there is a way to add textures in an already created .pack file instead of repacking all the textures again with the new additions.
Atlases support paging, basically, you append a new page to the atlas.
Add a blank line to the pack file and then start the next atlas. Either pack the next page and copy/paste the file to the end or write it manually.
This line is where it starts a new page:
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java#L110
What I like to do during development is repacking all raw images each time I run the project. This off course can be commented out to safe time but for my personal projects packing rarely exceeds a couple of seconds. So as long as you do not change existing filenames all changes and additions will be pushed trough.
I usually create a separate folder within the project folder called images. Here I put all my images, if I want to have my packs categorized I create additional folders to pack separately. Then in the desktop module I add the following lines:
Settings settings = new Settings();
//settings.XXXXXX change packer settings to your preferences.
//Since I set my working folder to android/assets I need to go down 2
//folders to get into the root of the project and access images.
//Likewise, for output I already start in my assets folder.
//So setting the path might differ depending on your working/asset folder.
TexturePacker.process(settings, "../../images/tileset01", "tilesets", "tileset01");
In the above scenario I have put all my separate images for tileset01 in the folder project\images\tileset01 and they will be packed into project\android\assets\tilesets as tileset01.png and tileset01.pack.
Related
The problem
In PhpStorm I have a style.css- and a app.js-file that I have to upload to a server over and over again. I'm trying to automate it.
They're compiled by Webpack, so they are generated/compiled. Which means that I can't simply use the 'Tools' >> 'Deployment' >> 'Upload to...' (since that file isn't and won't every be open).
What I currently do
At the moment, every time I want to see the changed I've done, then I do this (for each file):
Navigate to the files in the file-tree (using the mouse)
Select it
The I've set up a shortcut for Main menu >> Tools >> Deployment >> Upload to..., where-after I select the server I want to upload to.
I do this approximately 100+ times per day.
The ideal solution
The ideal solution would be, that if I pressed a shortcut like CMD + Option + Shift + G
That it then uploaded a selection of files (a scope?) to a predefined remote server.
Solution attempts
Open and upload.
Changing to those files (using CMD + p) and then uploading them (once they're open). But the files are generated, which means that it takes PhpStorm a couple of seconds to render the content (which is necessary before I can do anything with the file) - so that's not faster.
Macro.
Recording a macro, uploading the two files, looking like this:
If I go to the menu and trigger the Macro, then it works. So far so good.
But if I assign a shortcut key and trigger that shortcut while in a file, then it shows me this:
And if I press '1' (for it to upload to number 1 on the list), then it uploads the file that I'm currently in(!?), and not the two files from my macro.
I've tried several different shortcuts (to rule out some kind of keyboard-shortcut-clash):
CMD + Option + CTRL + 0
CMD + Shift 0
CMD + ;
... Same result.
And the PhpStorm Macro's doesn't seem to give me that many options anyways.
Keyboard Maestro.
I've tried doing it using Keyboard Maestro.
But I can't get it setup right. Because if it can't find the folders (if they're off-screen or if I'm in a different project and forgot to adjust they shortcuts), then it blasts through the rest of the recorded actions, resulting in chaos. Ideally it should stop, if it can't find the file on the screen.
Update1 - External program
Even if it's not possible to do in PhpStorm, - are there then another program that I could achieve this with?
Update2 - Automatic Deployment in PhpStorm
I've previously used this, - but I've had happen a few times that I started sync'ing waaaay to many files, overwriting critical core files. It seems smart, but can possibly tear down walls if I've forgotten to define an ignore properly.
I wish there was an 'Automatic Deployment for theses files'-function.
Update3 - File Watchers
I looked into file-watchers ( recommendation from #LazyOne ). Based on this forum thread, then file watchers cannot be used to upload files.
It is possible to accomplish it using external program scp (Secure Copy Protocol):
Steps:
1. Create a Scope (for compiled files app.js and style.css)
2. Create a Custom File Watcher with scp over that Scope
Start with Scope:
Create a Local Scope with name scp files for your compiled files directory (I will assume that your webpack compiles into dist directory):
Then, to add dist directory into Scope, select that folder and click on Include Recursively. Apply and Move to File Watchers
Create a custom template for File Watcher:
Choose a Name
Choose File type as Any
Choose Scope as scp files(created earlier)
Choose Program as scp
Choose Arguments as $FileName$ REMOTE_USER#REMOTE_HOST:/REMOTE_DIR_PATH/$FileName$
Choose Working directory as $FileDir$
That's it, basically what we have done is every time when a file in that scope changes, that file is copied with scp to the remote server to the corresponding path.
Voila. Apply Everything and recompile your project and you will see that everything is uploaded to the server.
(I assumed that you have already set up your ssh client; Generated public/private keys; Added a public key in your remote server; And, know ssh credentials to connect to your remote server)
I figured this out myself. I posted the answer here.
The two questions are kind of similar but not identical.
This way I found is also not the best, since it stores the server password in clean text. So I'll leave the question open, in case someone can come up with a better way to achieve this.
I'm using PhpStorm 10.0.4
When I start typing characters in project tool window it searchs for files containing typed text.
Is it possible to change this behavior so only files that begins with typed text would be matched?
Is it possible to change this behavior so only files that begins with typed text would be matched?
AFAIK no. There are no GUI settings for this at all.
Plus, this Speed Search is used in many places/tool windows and search logic is the same.
P.S. If you need to search for files .. why not try more appropriate (in general sense) Navigate | File... instead?
Speed Search only finds items in already expanded nodes (as it's a basic search on already displayed text) .. but Navigate | File... will look for files everywhere in the project.
It's not possible directly but you can create and use a scope for that.
Open Settings and go the Appearance & Behaviour -> Scopes. Create a new scope, give it a name (let's say "My Files") and put file:*/c* in the Pattern edit box.
In the big list of files under the Pattern edit box you can preview its effects. The files that are included in the scope are colored in green, the directories that contain included files are colored in blue.
This simple pattern selects only the files whose name start with c, in all directories. You can use slightly more complex filters using wild cards, include or exclude entire directories etc. With a little practice you can create filters that match usual needs pretty well.
When you are pleased with the scope definition, close the Settings box and go back to the Project view. Click on the arrow next to Project and you'll get a list of views of the project files. All the scopes you created should be there. Select "My Files" and only the files (and directories) included in that scope will be displayed in the Project view.
It is not a dynamic filter, you have to work a little to set it up, but it is useful when you work on large projects, with thousands of files, and you need to hide the files not important for your task.
I opened my project on another computer, and the files where I'd been using a file watcher were expanded, like before they used to be nested like home.scss is now after I run the watcher once on that file.
Is there a way to automatically make all the files be nested?
Because when adding new files and folder with git, it would be quite troublesome to go into each and every file in order to make them become nested.
Like I have some minified JavaScript files that used to be nested, but now is expanded for some reason.
Hope you understand. Thank you.
Edit: Nested***
Is there a way to automatically make all the files go under a caret like that?
Unfortunately not. Such nesting information (to "go under a caret" as you are saying) is taken from "Output path to refresh" field of the corresponding File Watcher.
You have to run file watcher for such files at least once in order to see files nested like you have it on your another computer.
Here is how you can run File Watchers manually without the need to modify those files (so no extra history will appear in your git (or whatever VCS you may be using there)).
https://stackoverflow.com/a/20012655/783119
P.S.
In PhpStorm 2016.3 (the next version that will be released in 1.5-2 months or so) such nesting will be done automatically (the most common combinations) so there will be no need to have File Watchers for providing such info.
If you wish -- you can try EAP build right now (EAP means Early Access Program .. which is sort of Alpha/Beta builds (simply speaking).. and therefore some bugs for new functionality might be present and performance may not be optimal).
My .fla is about 600mb big due to enormous amount of library objects.
I have 15.500 objects in library and most of them are images. This is probably bad practice, but my client required to have these images inside of it instead of loading them dynamically from some external source.
I have already reduced the size of the images as much as possible while still maintaining good quality.
I'm publishing for Flash Player, and already tried different versions.
Basicly my app is fairly simple test paper app, populating 20 test papers with simple multiple choise questions. Each test paper has 150 questions divided into 4 sections, and each question contains 1 question image and 4 answer images to choose from. After user picks his/her answer, these image instances are being deleted and new ones are being created.
I've heard that there's magical limit of 16.000 for everything like instances and so on, so it should stay right about under it as the code itself is quite simple and there's not many other instances after these images.
Besides my ugly file size, I'm also pushing all these images from library into arrays in a loop:
(linkage names are for example "Paper1_Chem_Q1_C.jpg", and "_X" marks the correct answer - that's why I unshift that one)
var sectionLengths:Array = [40,40,45,25];
var prefixes:Array = ["Phys","Chem","Maths","Eng_Reas"];
var prefixes2:Array = ["A","B","C","D"];
for(var p:int = 0; p<20; p++){ //test papers loop
for(var s:int = 0; s<4; s++){ //sections loop
var fillQArray:Array = this["tp"+(p+1)+"section"+(s+1)+"questions"];
var fillAArray:Array = this["tp"+(p+1)+"section"+(s+1)+"answers"];
for(var q:int = 0; q<sectionLengths[s]; q++){ //question loop
if(ApplicationDomain.currentDomain.hasDefinition(String("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)))){
fillQArray.push(getDefinitionByName("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)) as Class);
var qa:Array = new Array();
for(var a:int = 0; a<4; a++){ //answers loop
if(ApplicationDomain.currentDomain.hasDefinition(String("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)+"_"+prefixes2[a]))){
qa.push(getDefinitionByName("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)+"_"+prefixes2[a]));
}else if(ApplicationDomain.currentDomain.hasDefinition(String("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)+"_"+prefixes2[a]+"_X"))){
qa.unshift(getDefinitionByName("Paper"+(p+1)+"_"+prefixes[s]+"_Q"+(q+1)+"_"+prefixes2[a]+"_X"));
}
}
fillAArray.push(qa);
}
}
}
}
This loop surely does the job, but takes some time to run. Also, I predefine a LOT of arrays before it, so can this be another potential issue?
During development I've tested everything with few test papers, and it all worked like a charm, but now when I imported all the rest of the images, it gets stuck on publish. I left it to publish for the whole night, but now at morning it's once again stuck and I have to kill Flash process in order to quit it.
I have also increased memory amount from jvm.ini already to 2048m, so it doesn't give anymore the warning dialog regarding to too small JVM memory.
All suggestions are more than welcome.
I finally got it working, thanks to Vesper!
Here's detailed instructions for Flash Professional CC (so detailed becouse this was all new to me, and I spent almost 2 days for this failing multiple times):
Step 1 - Publish SWC:
Create empty .fla and import your images to library. Select all the
images and open properties with mouse2 button. At ActionScript tab
select Export for ActionScript. Make sure that also Export in frame 1 is activated.
Define a Classname for your project at Properties panel, for example: images_swc.
Go to Publish Settings and publish only SWC.
Notes:
In my case I had to create 3 SWC files becouse of the amount of images (15000+).
While adding/removing large amount of images to/from library, and while publishing a SWC, Flash Professional stopped responding and it looked like a crash, but in 30-60mins it succesfully finished!
When it was over an hour in "not responding" -state, I killed Flash process and tried with smaller amount of images.
First I created my "empty" .fla by removing everything but images from my main project, but somehow it didn't export correct images during SWC publish. But after I Saved As.. my image project, it worked like a charm.
Always when Flash notified about low JVM memory, I doubled the memory value in jvm.ini and started over. (Had eventually 4096m.)
Step 2 - Use SWC in your main project:
File -> Publish Settings -> Advanced ActionScript 3.0 Settings (wrench -icon at top-right-corner) -> Library path tab -> Click Browse to SWC file, locate your SWC and click OK.
Create empty .as file and type every image classname into it. Idea here is to mention all the images from SWC so that compiler understands that you want to include them in your main project. e.g:
package {
public class Assets {
image_1;
image_2;
image_3;
}
}
In your main project, include Assets.as and your SWC-file(s):
import Assets;
import images_swc;
Refer to your images with:
getDefinitionByName("image_1")
Final notes:
If you forget your "SWC classname", change the extension of your SWC file to .zip, open it, and you'll find your classname and other details from the xml file inside of it.
To get filenames of large amount of images for your .as file (assuming you have same classnames and filenames for your images), you can use windows command prompt and "dir /s > filename.txt" -command to gether filenames into txt-file. Myself I used free version of Directory List & Print which also finds files from subfolders, pasted the file list into Assets.as and used Find & Replace functionality in Flash to replace ".jpg" with ";".
So, I had over 15000 images, turned them into 3 SWC files = 15-20 megs per SWC, and my final .swf was around 55 megs - and it was compiled in couple minutes, which makes this pretty perfect solution for my project.
#Vesper, thanks again! :)
As far as I know, the only way to include a folder in an Air package (in Flash Pro, not Builder) is through the GUI:
Publish Settings > Player Settings > General Tab > Included Files
... but it's kind of a huge hassle to manually add and remove folders over and over again if you have to publish the app with a dozen different versions of the content, you know?
Is there a way to conditionally include folders based on text somewhere - the app config xml, maybe? or something else that will be checked when the APK is compiled? That way I could just copy and paste in the folder name to switch which asset folder is being included, instead of going through the whole process inside of the flash IDE?
This idea might possibly be of some use although it could require some management due to possibly meaning you have duplicated assets.
I typically store all my assets inside an 'includes' folder/directory and just add this to the Settings > Include Files pane.
I also have folders which store the target specific includes, such as 'IOS' and 'ANDROID', (but aren't added to the Include Files pane).
When publishing, I swap out the contents of the includes folder. So it's just a case of deleting the existing contents if the includes folder and copy/pasting from the relevant source folder into the includes folder.
Hope that makes sense.
There are a couple of things you could do, though they're not 100% solutions per se.
1) Use conditional compilation:
Depending on how your imports/includes are set up, you could change it to always be the same file, but change the code/embed inside depending on a compile time constant. You can add a compile constant by going to File > Publish Paramaters > Flash (tab) > Parameters > Configure Constants:
Your constants would be in the form CONFIG::debug or FOO::bar, then in code, you wrap your code like this:
CONFIG::debug
{
// code is only included if CONFIG::debug is true at compile time
}
Then, by flipping constants, you can include or exclude blocks of code. There's a bit more detail here: http://divillysausages.com/blog/as3_conditional_compilation
NOTE: this is much easier to do in an IDE like FlashDevelop.
2) Use an external IDE
Taking the FlashDevelop example, when building for mobile, a number of .bat files are created. Depending on the environment vars set, you can include/exclude folders as you wish. I do this to include different assets depending on if it's a desktop, Android, or iOS build.
3) Use the Flex SDK command line or ANT
With either of these, you can specify a config.xml file for the files that you want to include. External IDEs (like FD) use the command line directly, so you can almost copy/paste the command if necessary.
For ANT, it's not my strongest point, but you can find out a bit more here: http://charlespatricknewman.com/blog/?p=325