Java Code Examples for com.kotcrab.vis.ui.widget.file.FileChooser#setViewMode()

The following examples show how to use com.kotcrab.vis.ui.widget.file.FileChooser#setViewMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
protected void exportUIImages() {
	FileChooser fileChooser = new FileChooser(Mode.OPEN);
	fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
	fileChooser.setViewMode(ViewMode.LIST);

	fileChooser.setSelectionMode(SelectionMode.DIRECTORIES);
	getStage().addActor(fileChooser);

	fileChooser.setListener(new FileChooserListener() {

		@Override
		public void selected(Array<FileHandle> files) {
			try {
				// fileChooser.setTitle("Select the file to export the
				// project texts");

				ImageUtils.unpackAtlas(new File(Ctx.project.getAssetPath() + Project.UI_PATH + "/1/ui.atlas"),
						files.get(0).file());

				Message.showMsg(getStage(), "UI Atlas images exported sucessfully.", 4);
			} catch (Exception e) {
				Message.showMsg(getStage(), "There was a problem exporting images from UI Atlas.", 4);
				EditorLogger.printStackTrace(e);
			}
		}

		@Override
		public void canceled() {

		}
	});

}
 
Example 2
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void exportTSV() {

		FileChooser fileChooser = new FileChooser(Mode.SAVE);
		fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
		fileChooser.setViewMode(ViewMode.LIST);

		fileChooser.setSelectionMode(SelectionMode.FILES);
		getStage().addActor(fileChooser);

		fileChooser.setListener(new FileChooserListener() {

			@Override
			public void selected(Array<FileHandle> files) {
				try {
					// fileChooser.setTitle("Select the file to export the
					// project texts");

					I18NUtils.exportTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH,
							files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");

					Message.showMsg(getStage(), files.get(0).file().getName() + " exported sucessfully.", 4);
				} catch (IOException e) {
					Message.showMsg(getStage(), "There was a problem generating the .tsv file.", 4);
					EditorLogger.printStackTrace(e);
				}
			}

			@Override
			public void canceled() {

			}
		});
	}
 
Example 3
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void importTSV() {

		FileChooser fileChooser = new FileChooser(Mode.OPEN);
		fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
		fileChooser.setViewMode(ViewMode.LIST);

		fileChooser.setSelectionMode(SelectionMode.FILES);
		getStage().addActor(fileChooser);

		fileChooser.setListener(new FileChooserListener() {

			@Override
			public void selected(Array<FileHandle> files) {
				try {
					// chooser.setTitle("Select the .tsv file to import");

					I18NUtils.importTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH,
							files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");

					// Reload texts
					Ctx.project.getI18N().load(Ctx.project.getChapter().getId());

					Message.showMsg(getStage(), files.get(0).file().getName() + " imported sucessfully.", 4);

				} catch (IOException e) {
					Message.showMsg(getStage(), "There was a problem importing the .tsv file.", 4);
					EditorLogger.printStackTrace(e);
				}
			}

			@Override
			public void canceled() {

			}
		});
	}
 
Example 4
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
protected void createUIAtlas() {
	FileChooser fileChooser = new FileChooser(Mode.OPEN);
	fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
	fileChooser.setViewMode(ViewMode.LIST);

	fileChooser.setSelectionMode(SelectionMode.DIRECTORIES);
	getStage().addActor(fileChooser);

	fileChooser.setListener(new FileChooserListener() {

		@Override
		public void selected(Array<FileHandle> files) {

			List<String> res = Ctx.project.getResolutions();

			for (String r : res) {
				float scale = Float.parseFloat(r);

				try {
					int maxWH = (int) (ImageUtils.getRecommendedAtlasSize() * scale);

					ImageUtils.createAtlas(files.get(0).file().getAbsolutePath(),
							Ctx.project.getAssetPath() + Project.UI_PATH + "/" + r, "ui" + ".atlas", scale, maxWH,
							maxWH, TextureFilter.Linear, TextureFilter.Nearest, "png", false);
				} catch (IOException e) {
					EditorLogger.error(e.getMessage());
					Message.showMsgDialog(getStage(), "Error creating atlas", e.getMessage());
					return;
				}
			}

			Message.showMsg(getStage(), "UI Atlas created sucessfully.", 4);
		}

		@Override
		public void canceled() {

		}
	});

}