Skip to content

Commit

Permalink
^ [Платформа] Для разработческих сборок номер версии теперь содержит …
Browse files Browse the repository at this point in the history
…дату сборки (берётся

    как дата запускаемого файла).
  • Loading branch information
realsonic committed May 19, 2022
1 parent e20c684 commit 1bcc83a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
5 changes: 4 additions & 1 deletion docs/notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@
* [Платформа] Лог теперь пишется в папку пользователя, т.к. в папке, куда установлен
ЯРИЛ, может не быть прав на запись файла.
16.05.2022
* [Ядро] ifml2/ifml2#51 Ошибка ядра: получение доступного содержимого проверяет только
* [Ядро] ifml2/ifml2#51 Ошибка ядра: получение доступного содержимого проверяет только
первую роль с нужным триггером
19.05.2022
^ [Платформа] Для разработческих сборок номер версии теперь содержит дату сборки (берётся
как дата запускаемого файла).

-----------------------------------------------------------------------------------------------
Выпуск 2016/5
Expand Down
28 changes: 28 additions & 0 deletions src/ifml2/CommonUtils.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package ifml2;

import ifml2.engine.EngineVersion;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import java.io.File;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;

public class CommonUtils
{
Expand Down Expand Up @@ -64,4 +69,27 @@ public static Cipher createCipher() throws NoSuchAlgorithmException, NoSuchPaddi
}
return stringBuilder.toString();
}*/

public static Date getBuildDate(){
try {
String jarPath = CommonUtils.class
.getProtectionDomain()
.getCodeSource()
.getLocation()
.toURI()
.getPath();
File jarFile = new File(jarPath);
return new Date(jarFile.lastModified());
} catch (URISyntaxException e) {
return null;
}
}

public static String getVersion(){
String versionStr = EngineVersion.VERSION;
if (EngineVersion.IS_DEVELOPER_VERSION){
versionStr += String.format("[📅%1$td/%1$tb/%1$ty]", getBuildDate());
}
return versionStr;
}
}
3 changes: 1 addition & 2 deletions src/ifml2/Launcher.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ifml2;

import ifml2.editor.gui.Editor;
import ifml2.engine.EngineVersion;
import ifml2.players.guiplayer.GUIPlayer;
import ifml2.tests.gui.TestRunner;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -68,7 +67,7 @@ public String toString()
return "Тестер";
}
};
Object answer = JOptionPane.showInputDialog(null, "Что запустить?", format("%s %s", RUSSIAN_PRODUCT_NAME, EngineVersion.VERSION),
Object answer = JOptionPane.showInputDialog(null, "Что запустить?", format("%s %s", RUSSIAN_PRODUCT_NAME, CommonUtils.getVersion()),
JOptionPane.QUESTION_MESSAGE, null, new Object[]{playerOption, editorOption, testerOption}, playerOption);
if(playerOption.equals(answer))
{
Expand Down
3 changes: 1 addition & 2 deletions src/ifml2/editor/gui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ifml2.editor.IFML2EditorException;
import ifml2.editor.gui.editors.*;
import ifml2.editor.gui.forms.ListEditForm;
import ifml2.engine.EngineVersion;
import ifml2.om.Action;
import ifml2.om.*;
import ifml2.players.guiplayer.GUIPlayer;
Expand Down Expand Up @@ -164,7 +163,7 @@ private void updateTitle()
{
String fileName = storyFile != null ? storyFile.getName() : "новая история";
String storyEditedMark = isStoryEdited ? " - * история не сохранена" : "";
String editorTitle = format("%s Редактор %s -- %s%s", RUSSIAN_PRODUCT_NAME, EngineVersion.VERSION, fileName,
String editorTitle = format("%s Редактор %s -- %s%s", RUSSIAN_PRODUCT_NAME, CommonUtils.getVersion(), fileName,
storyEditedMark);
setTitle(editorTitle);
}
Expand Down
1 change: 1 addition & 0 deletions src/ifml2/engine/EngineVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface EngineVersion
{
String VERSION = "(В РАЗРАБОТКЕ)";
boolean IS_DEVELOPER_VERSION = true;
}
5 changes: 2 additions & 3 deletions src/ifml2/players/guiplayer/GUIPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import static ifml2.CommonConstants.*;
import static ifml2.GUIUtils.*;
import static ifml2.engine.EngineVersion.VERSION;
import static java.lang.String.format;
import static javax.swing.JOptionPane.*;

Expand Down Expand Up @@ -58,7 +57,7 @@ public class GUIPlayer extends JFrame implements IOutputPlainTextProvider, IOutp

private GUIPlayer(boolean fromTempFile)
{
super(format("%s Плеер %s", RUSSIAN_PRODUCT_NAME, VERSION));
super(format("%s Плеер %s", RUSSIAN_PRODUCT_NAME, CommonUtils.getVersion()));
this.isFromTempFile = fromTempFile;

setContentPane(mainPanel);
Expand Down Expand Up @@ -570,7 +569,7 @@ private void updateTitle()
titleFile = file.getName();
}
}
setTitle(format("%s Плеер %s -- %s", RUSSIAN_PRODUCT_NAME, VERSION, titleFile));
setTitle(format("%s Плеер %s -- %s", RUSSIAN_PRODUCT_NAME, CommonUtils.getVersion(), titleFile));
}

private String getCommandText()
Expand Down
3 changes: 1 addition & 2 deletions src/ifml2/tests/gui/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ifml2.CommonConstants;
import ifml2.CommonUtils;
import ifml2.GUIUtils;
import ifml2.engine.EngineVersion;
import ifml2.tests.IFMLTestPlan;
import ifml2.tests.TestManager;

Expand Down Expand Up @@ -35,7 +34,7 @@ public class TestRunner extends JFrame

public TestRunner()
{
super(format("%s Тестер %s", RUSSIAN_PRODUCT_NAME, EngineVersion.VERSION));
super(format("%s Тестер %s", RUSSIAN_PRODUCT_NAME, CommonUtils.getVersion()));
setContentPane(mainPanel);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
GUIUtils.packAndCenterWindow(this);
Expand Down

0 comments on commit 1bcc83a

Please sign in to comment.