Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xlam committed Nov 21, 2018
2 parents 1dd0475 + 0195f36 commit 8cd9f86
Show file tree
Hide file tree
Showing 34 changed files with 558 additions and 283 deletions.
25 changes: 25 additions & 0 deletions .checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">

<suppressions>
<suppress checks="JavadocStyle" files=".*\.java" />
<suppress checks="SummaryJavadoc" files=".*\.java" />
<suppress checks="JavadocParagraph" files=".*\.java" />
<suppress checks="JavadocMethod" files=".*\.java" />
<suppress checks="JavadocTagContinuationIndentation" files=".*\.java" />
<suppress checks="SingleLineJavadoc" files=".*\.java" />

<suppress checks="LineLength" files=".*\.java" />
<suppress checks="OperatorWrap" files=".*\.java" />
<suppress checks="ParameterName" files=".*\.java" />
<suppress checks="AvoidStarImport" files=".*\.java" />
<suppress checks="MemberName" files=".*\.java" />
<suppress checks="LocalVariableName" files=".*\.java" />
<suppress checks="MethodName" files=".*\.java" />
<suppress checks="CustomImportOrder" files=".*\.java" />
<suppress checks="OverloadMethodsDeclarationOrder" files=".*\.java" />
<suppress checks="VariableDeclarationUsageDistance" files=".*\.java" />
</suppressions>
15 changes: 8 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ru</groupId>
<artifactId>cyberbiology</artifactId>
<version>1.2.0</version>
<version>1.3-dev</version>

<name>cyberbiology</name>
<description>Add project description here</description>
Expand Down Expand Up @@ -101,13 +101,13 @@
<replacementProperty>
<property>git.commit.id.describe</property>
<propertyOutputSuffix>regex</propertyOutputSuffix>
<token>^(v?)([[\.-]a-zA-Z0-9]+)-([^0])-(g.+(dirty)?)$</token>
<value>${project.version}+$3.$4</value>
<token>^v?([0-9][[\\.-]0-9a-zA-Z]*)-(0)-(g[0-9a-h]+)((-dirty)?$)</token>
<value>${project.version}$4</value>
</replacementProperty>
<replacementProperty>
<property>git.commit.id.describe.regex</property>
<token>^v?([[\.-]a-zA-Z0-9]+)-(0)-(g\w+)(-dirty)?$</token>
<value>${project.version}$4</value>
<token>^v?([0-9][[\\.-]0-9a-zA-Z]*)-([1-9][0-9]*)-(g.+(dirty)?)$</token>
<value>${project.version}+$2.$3</value>
</replacementProperty>
</replacementProperties>
</configuration>
Expand All @@ -125,11 +125,12 @@
</dependencies>
<configuration>
<configLocation>${basedir}/.checkstyle.xml</configLocation>
<suppressionsLocation>${basedir}/.checkstyle-suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<!-- <executions>
<execution>
<id>validate</id>
<phase>validate</phase>
Expand All @@ -142,7 +143,7 @@
<goal>check</goal>
</goals>
</execution>
</executions>
</executions>-->
</plugin>
</plugins>
</build>
Expand Down
415 changes: 216 additions & 199 deletions src/main/java/ru/cyberbiology/Bot.java

Large diffs are not rendered by default.

40 changes: 28 additions & 12 deletions src/main/java/ru/cyberbiology/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ public void paint(Graphics g) {
};

private final ProjectProperties properties;
private final SettingsDialog settingsDialog;

public MainWindow() {

properties = ProjectProperties.getInstance();
settingsDialog = new SettingsDialog(this, true);

setTitle("CyberBiology " + getVersionFromProperties());
setPreferredSize(new Dimension(1024, 768));
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Expand All @@ -107,7 +111,7 @@ public MainWindow() {
setExtendedState(NORMAL);
}

private void showPropertyDialog() {
private void showSaveDirectoryDialog() {
JTextField fileDirectoryName = new JTextField();
fileDirectoryName.setText(getFileDirectory());
final JComponent[] inputs = new JComponent[]{
Expand All @@ -119,7 +123,7 @@ private void showPropertyDialog() {
}
}

protected void setFileDirectory(String name) {
private void setFileDirectory(String name) {
properties.setFileDirectory(name);
}

Expand Down Expand Up @@ -205,6 +209,8 @@ public void mouseClicked(MouseEvent e) {
case 3:// есть MPREV и MNEXT
buf.append("есть MPREV и MNEXT</p>");
break;
default:
break;
}
buf.append("<p>c_blue=").append(bot.c_blue);
buf.append("<p>c_green=").append(bot.c_green);
Expand All @@ -215,13 +221,13 @@ public void mouseClicked(MouseEvent e) {

//buf.append("");
IBotGeneController cont;
for (int i = 0; i < Bot.MIND_SIZE; i++) {//15
for (int i = 0; i < Bot.MIND_SIZE; i++) { //15
int command = bot.mind[i]; // текущая команда

// Получаем обработчика команды
cont = Bot.geneController[command];
if (cont != null)// если обработчик такой команды назначен
{
cont = bot.getCurrentCommand();
// если обработчик такой команды назначен
if (cont != null) {
buf.append("<p>");
buf.append(String.valueOf(i));
buf.append("&nbsp;");
Expand Down Expand Up @@ -258,8 +264,6 @@ private void setupMenuBar() {
JMenu paintStepMenu = new JMenu("Шаг отрисовки");
JMenu botSizeMenu = new JMenu("Размер бота");
JMenu settingsMenu = new JMenu("Настройки");
settingsMenu.add(paintStepMenu);
settingsMenu.add(botSizeMenu);
menuBar.add(fileMenu);
menuBar.add(viewMenu);
menuBar.add(worldEventsMenu);
Expand Down Expand Up @@ -296,6 +300,7 @@ private void setupMenuBar() {
world.generateAdam();
paint();
world.start();
runItem.setText("Пауза");
});

JMenuItem mutateItem = new JMenuItem("Cлучайная мутация");
Expand Down Expand Up @@ -354,9 +359,9 @@ private void setupMenuBar() {
PlayerWindow fw = new PlayerWindow();
});

JMenuItem optionItem = new JMenuItem("Установки");
optionItem.addActionListener((ActionEvent e) -> {
showPropertyDialog();
JMenuItem savePathItem = new JMenuItem("Каталог сохранения");
savePathItem.addActionListener((ActionEvent e) -> {
showSaveDirectoryDialog();
});

JMenuItem exitItem = new JMenuItem("Выход");
Expand All @@ -380,10 +385,12 @@ private void setupMenuBar() {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileFilter() {
private static final String SUFFIX = ".frame.cb.zip";

@Override
public boolean accept(File f) {
return f.isDirectory() || f.getName().endsWith(SUFFIX);
}

@Override
public String getDescription() {
return "Сохраненный мир (*" + SUFFIX + ")";
Expand All @@ -399,18 +406,27 @@ public String getDescription() {
}
});

JMenuItem settingsDialogItem = new JMenuItem("Параметры");
settingsDialogItem.addActionListener((ActionEvent e) -> {
settingsDialog.showSettingsDialog();
});

fileMenu.add(runItem);
fileMenu.add(restartItem);
fileMenu.add(snapShotItem);
fileMenu.add(loadWorldItem);
fileMenu.add(recordItem);
fileMenu.add(openItem);
fileMenu.addSeparator();
fileMenu.add(optionItem);
fileMenu.add(savePathItem);
fileMenu.addSeparator();
fileMenu.add(exitItem);
worldEventsMenu.add(mutateItem);
worldEventsMenu.add(adressJumpItem);
settingsMenu.add(paintStepMenu);
settingsMenu.add(botSizeMenu);
settingsMenu.addSeparator();
settingsMenu.add(settingsDialogItem);

/**
* Меню выбора вида.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/cyberbiology/PlayerWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void mouseClicked(MouseEvent e) {
int command = bot.mind[i]; // текущая команда

// Получаем обработчика команды
cont = Bot.geneController[command];
cont = bot.getCurrentCommand();
if (cont != null)// если обработчик такой команды назначен
{
buf.append("<p>");
Expand Down
Loading

0 comments on commit 8cd9f86

Please sign in to comment.