Skip to content

Commit 5c58853

Browse files
committed
Missing file from latest commit + duplicatePadding=false
1 parent 46f5594 commit 5c58853

File tree

2 files changed

+133
-1
lines changed

2 files changed

+133
-1
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/common/ImageUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static void createAtlas(String inDir, String outdir, String name, float s
180180
settings.pot = false;
181181
settings.paddingX = 2;
182182
settings.paddingY = 2;
183-
settings.duplicatePadding = true;
183+
settings.duplicatePadding = false;
184184
settings.edgePadding = true;
185185
settings.rotation = false;
186186
settings.minWidth = 16;
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*******************************************************************************
2+
* Copyright 2014 Rafael Garcia Moreno.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
******************************************************************************/
16+
package com.bladecoder.engineeditor.ui;
17+
18+
import java.io.File;
19+
import java.io.IOException;
20+
import java.util.ArrayList;
21+
import java.util.List;
22+
23+
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
24+
import com.bladecoder.engine.actions.Param;
25+
import com.bladecoder.engineeditor.Ctx;
26+
import com.bladecoder.engineeditor.common.Message;
27+
import com.bladecoder.engineeditor.common.ModelTools;
28+
import com.bladecoder.engineeditor.common.RunProccess;
29+
import com.bladecoder.engineeditor.ui.panels.EditDialog;
30+
import com.bladecoder.engineeditor.ui.panels.FileInputPanel;
31+
import com.bladecoder.engineeditor.ui.panels.InputPanel;
32+
import com.bladecoder.engineeditor.ui.panels.InputPanelFactory;
33+
34+
public class CompileInkDialog extends EditDialog {
35+
36+
private static final String FILE_PROP = "compileink.file";
37+
private static final String INKLECATE_PROP = "compileink.inklecate";
38+
private static final String LANG_PROP = "compileink.lang";
39+
private static final String EXTRACT_TEXTS_PROP = "compileink.extractTexts";
40+
41+
private static final String INFO = "Compile the ink script using Inklecate.\n Inklecate must be installed in your computer, download here: https://github.com/inkle/ink/releases/latest.";
42+
43+
private InputPanel inklecatePath;
44+
private InputPanel file;
45+
private InputPanel extractTexts;
46+
private InputPanel lang;
47+
48+
public CompileInkDialog(Skin skin) {
49+
super("COMPILE INK SCRIPT", skin);
50+
51+
inklecatePath = new FileInputPanel(skin, "Select the inklecate folder",
52+
"Select the folder where the inklecate is installed", FileInputPanel.DialogType.DIRECTORY);
53+
54+
file = new FileInputPanel(skin, "Select the Ink script", "Select the Ink source script for your chapter",
55+
FileInputPanel.DialogType.OPEN_FILE);
56+
57+
extractTexts = InputPanelFactory.createInputPanel(skin, "Extract texts",
58+
"Extracts all texts in a .properties for I18N.", Param.Type.BOOLEAN, true, "true");
59+
60+
lang = InputPanelFactory.createInputPanel(skin, "Lang code",
61+
"The languaje code (ex. 'fr') where the texts are extracted. Empty for default.", false);
62+
63+
addInputPanel(inklecatePath);
64+
addInputPanel(file);
65+
addInputPanel(extractTexts);
66+
addInputPanel(lang);
67+
68+
setInfo(INFO);
69+
70+
if (Ctx.project.getEditorConfig().getProperty(FILE_PROP) != null)
71+
file.setText(Ctx.project.getEditorConfig().getProperty(FILE_PROP));
72+
73+
if (Ctx.project.getEditorConfig().getProperty(INKLECATE_PROP) != null)
74+
inklecatePath.setText(Ctx.project.getEditorConfig().getProperty(INKLECATE_PROP));
75+
76+
lang.setText(Ctx.project.getEditorConfig().getProperty(LANG_PROP));
77+
78+
if (Ctx.project.getEditorConfig().getProperty(EXTRACT_TEXTS_PROP) != null)
79+
extractTexts.setText(Ctx.project.getEditorConfig().getProperty(EXTRACT_TEXTS_PROP));
80+
}
81+
82+
@Override
83+
protected void ok() {
84+
compileInk();
85+
86+
Ctx.project.getEditorConfig().setProperty(FILE_PROP, file.getText());
87+
Ctx.project.getEditorConfig().setProperty(INKLECATE_PROP, inklecatePath.getText());
88+
89+
if (lang.getText() != null)
90+
Ctx.project.getEditorConfig().setProperty(LANG_PROP, lang.getText());
91+
92+
Ctx.project.getEditorConfig().setProperty(EXTRACT_TEXTS_PROP, extractTexts.getText());
93+
}
94+
95+
@Override
96+
protected boolean validateFields() {
97+
boolean ok = true;
98+
99+
if (!inklecatePath.validateField())
100+
ok = false;
101+
102+
if (!file.validateField())
103+
ok = false;
104+
105+
return ok;
106+
}
107+
108+
private void compileInk() {
109+
String outfile = Ctx.project.getModelPath() + "/" + new File(file.getText()).getName() + ".json";
110+
List<String> params = new ArrayList<>();
111+
params.add("-o");
112+
params.add(outfile);
113+
params.add(file.getText());
114+
boolean ok = RunProccess.runInklecate(new File(inklecatePath.getText()), params);
115+
116+
if (!ok) {
117+
Message.showMsgDialog(getStage(), "Error", "Error compiling Ink script.");
118+
return;
119+
}
120+
121+
if (extractTexts.getText().equals("true")) {
122+
try {
123+
ModelTools.extractInkTexts(outfile, lang.getText());
124+
} catch (IOException e) {
125+
Message.showMsgDialog(getStage(), "Error extracting Ink texts.", e.getMessage());
126+
return;
127+
}
128+
}
129+
130+
Message.showMsg(getStage(), "Ink script compiled successfully", 2);
131+
}
132+
}

0 commit comments

Comments
 (0)