Page 1 of 1
Source Code Autoformat
Posted: Mon Nov 18, 2013 11:09 am
by Todor Balabanov
Hi!
Is it possible source code auto-format to be done in Android Studio for all Java files in the project?
All the best,
Todor
Re: Source Code Autoformat
Posted: Mon Nov 18, 2013 12:20 pm
by Zukero
Hello and welcome to the forums !
I don't know about Android Studio. You can search for "IntelliJ Idea" in google. Android Studio is based on this software (a non-free Java IDE).
I use the Eclipse ADT bundle, as IMHO, android studio is not mature enough yet, and I'm more familiar with eclipse. In eclipse, you can use Ctrl+Shift+F to reformat a source file, or a whole project, or Ctrl+I to only redo the indentation of a selected piece of code.
However, if you intend to contribute some source code, I would advise against reformatting the files, as GIT would think you have changed all the lines of all the files.
Good luck !
Re: Source Code Autoformat
Posted: Sat Nov 23, 2013 5:03 pm
by Todor Balabanov
Thanks.
At the moment it is pretty difficult to read the code. I have better experience with Eclipse, but the tutorial says that Android Studio should be used and that is why I have asked for it.
May be the better question is why the source code is not auto-formated already?
Is there any chance project admins to take decision for source code auto-format?
I would like to contribute, but I think it is too early for me to offer something useful.
Todor
Re: Source Code Autoformat
Posted: Sat Nov 23, 2013 5:43 pm
by Zukero
Where did you get the source ?
I get it from Oskar's github repo, and it looks well formatted to me. Indent uses tab, opening brackets not on a new line, and methods parameters on a new line when numerous are the choices made.
Re: Source Code Autoformat
Posted: Sat Nov 23, 2013 5:50 pm
by Todor Balabanov
I see it seams it is my mistake. I am taking it from here:
https://code.google.com/p/andors-trail/ ... ndorsTrail
I see some interesting functions.
Posted: Sat Nov 23, 2013 6:13 pm
by Todor Balabanov
Do you thik that it will be useful to rewrite some of them?
Code: Select all
private static int getRandomConditionForRejuvenate(Player player) {
ArrayList<Integer> potentialConditions = new ArrayList<Integer>();
for (int i = 0; i < player.conditions.size(); ++i) {
ActorCondition c = player.conditions.get(i);
if (!c.isTemporaryEffect())
continue;
if (c.conditionType.isPositive)
continue;
if (c.conditionType.conditionCategory == ActorConditionType.ConditionCategory.spiritual)
continue;
potentialConditions.add(i);
}
if (potentialConditions.isEmpty())
return -1;
return potentialConditions.get(Constants.rnd
.nextInt(potentialConditions.size()));
}
Code: Select all
private static int getRandomConditionForRejuvenate2(Player player) {
int i = -1;
int count = 0;
int potentialConditions[] = new int[player.conditions.size()];
for (ActorCondition c : player.conditions) {
i++;
if (!c.isTemporaryEffect())
continue;
if (c.conditionType.isPositive)
continue;
if (c.conditionType.conditionCategory == ActorConditionType.ConditionCategory.spiritual)
continue;
potentialConditions[count++] = i;
}
if (count == 0)
return -1;
return potentialConditions[Constants.rnd.nextInt(count)];
}