<commit_before>/**
 * Copyright 2014 <NAME>
 * 
 * This file is part of VisEditor.
 * 
 * VisEditor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * VisEditor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with VisEditor.  If not, see <http://www.gnu.org/licenses/>.
 */

package pl.kotcrab.vis.editor;

import java.io.File;

import pl.kotcrab.vis.editor.event.Event;
import pl.kotcrab.vis.editor.event.EventListener;
import pl.kotcrab.vis.editor.event.ProjectStatusEvent;
import pl.kotcrab.vis.editor.event.ProjectStatusEvent.Status;
import pl.kotcrab.vis.editor.event.StatusBarEvent;
import pl.kotcrab.vis.editor.module.MenuBarModule;
import pl.kotcrab.vis.editor.module.ModuleContainer;
import pl.kotcrab.vis.editor.module.ProjectIOModule;
import pl.kotcrab.vis.editor.module.StatusBarModule;
import pl.kotcrab.vis.editor.module.TabsModule;
import pl.kotcrab.vis.editor.module.ToolbarModule;
import pl.kotcrab.vis.editor.module.project.AssetsManagerUIModule;
import pl.kotcrab.vis.editor.module.project.FileAccessModule;
import pl.kotcrab.vis.editor.module.project.Project;
import pl.kotcrab.vis.editor.module.project.ProjectInfoTabModule;
import pl.kotcrab.vis.editor.module.project.ProjectModuleContainer;
import pl.kotcrab.vis.editor.module.scene.SceneIOModule;
import pl.kotcrab.vis.editor.module.scene.SceneTabsModule;
import pl.kotcrab.vis.editor.ui.EditorFrame;
import pl.kotcrab.vis.editor.ui.tab.Tab;
import pl.kotcrab.vis.editor.ui.tab.TabViewMode;
import pl.kotcrab.vis.editor.util.EditorException;
import pl.kotcrab.vis.ui.VisTable;
import pl.kotcrab.vis.ui.VisUI;
import pl.kotcrab.vis.ui.util.DialogUtils;
import pl.kotcrab.vis.ui.widget.VisLabel;
import pl.kotcrab.vis.ui.widget.VisSplitPane;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

public class Editor extends ApplicationAdapter implements EventListener {
	public static Editor instance;

	private EditorFrame frame;

	private Stage stage;
	private Table root;

	// TODO move to module
	private Table mainContentTable;
	private Table tabContentTable;
	private VisTable projectContentTable;
	private VisSplitPane splitPane;

	private ModuleContainer moduleContainer;
	private ProjectModuleContainer projectModuleContainer;

	private boolean projectLoaded = false;

	private StatusBarModule statusBar;

	private Tab tab;

	public Editor (EditorFrame frame) {
		this.frame = frame;
	}

	@Override
	public void create () {
		instance = this;
		Assets.load();
		VisUI.load();
		VisUI.setDefualtTitleAlign(Align.center);

		App.eventBus.register(this);

		stage = new Stage(new ScreenViewport());
		Gdx.input.setInputProcessor(stage);

		mainContentTable = new Table();
		tabContentTable = new Table();
		projectContentTable = new VisTable(true);
		splitPane = new VisSplitPane(null, null, true);
		splitPane.setSplitAmount(0.7f);

		projectContentTable.add(new VisLabel("Project Content Manager has not been loaded yet"));

		root = new Table();
		root.setFillParent(true);
		stage.addActor(root);

		moduleContainer = new ModuleContainer();
		projectModuleContainer = new ProjectModuleContainer(moduleContainer);

		moduleContainer.add(new ProjectIOModule());

		// GUI modules
		moduleContainer.add(new MenuBarModule(projectModuleContainer));
		moduleContainer.add(new ToolbarModule());
		moduleContainer.add(new TabsModule());

		root.add(mainContentTable).expand().fill().row();
		root.row();

		moduleContainer.add(new StatusBarModule());

		moduleContainer.init();

		// debug section
		try {
			moduleContainer.get(ProjectIOModule.class).load((new File("F:\\Poligon\\TestProject")));
		} catch (EditorException e) {
			e.printStackTrace();
		}
	}

	public StatusBarModule getStatusBar () {
		return statusBar;
	}

	@Override
	public void resize (int width, int height) {
		stage.getViewport().update(width, height, true);
		moduleContainer.resize();
		projectModuleContainer.resize();
	}

	@Override
	public void render () {
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		stage.act(Gdx.graphics.getDeltaTime());
		if (tab != null) tab.render(stage.getBatch());<commit_msg>Debug: open test scene at startup<commit_after>/**
 * Copyright 2014 <NAME>
 * 
 * This file is part of VisEditor.
 * 
 * VisEditor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * VisEditor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with VisEditor.  If not, see <http://www.gnu.org/licenses/>.
 */

package pl.kotcrab.vis.editor;

import java.io.File;

import pl.kotcrab.vis.editor.event.Event;
import pl.kotcrab.vis.editor.event.EventListener;
import pl.kotcrab.vis.editor.event.ProjectStatusEvent;
import pl.kotcrab.vis.editor.event.ProjectStatusEvent.Status;
import pl.kotcrab.vis.editor.event.StatusBarEvent;
import pl.kotcrab.vis.editor.module.MenuBarModule;
import pl.kotcrab.vis.editor.module.ModuleContainer;
import pl.kotcrab.vis.editor.module.ProjectIOModule;
import pl.kotcrab.vis.editor.module.StatusBarModule;
import pl.kotcrab.vis.editor.module.TabsModule;
import pl.kotcrab.vis.editor.module.ToolbarModule;
import pl.kotcrab.vis.editor.module.project.AssetsManagerUIModule;
import pl.kotcrab.vis.editor.module.project.FileAccessModule;
import pl.kotcrab.vis.editor.module.project.Project;
import pl.kotcrab.vis.editor.module.project.ProjectInfoTabModule;
import pl.kotcrab.vis.editor.module.project.ProjectModuleContainer;
import pl.kotcrab.vis.editor.module.scene.EditorScene;
import pl.kotcrab.vis.editor.module.scene.SceneIOModule;
import pl.kotcrab.vis.editor.module.scene.SceneTabsModule;
import pl.kotcrab.vis.editor.ui.EditorFrame;
import pl.kotcrab.vis.editor.ui.tab.Tab;
import pl.kotcrab.vis.editor.ui.tab.TabViewMode;
import pl.kotcrab.vis.editor.util.EditorException;
import pl.kotcrab.vis.ui.VisTable;
import pl.kotcrab.vis.ui.VisUI;
import pl.kotcrab.vis.ui.util.DialogUtils;
import pl.kotcrab.vis.ui.widget.VisLabel;
import pl.kotcrab.vis.ui.widget.VisSplitPane;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.utils.viewport.ScreenViewport;

public class Editor extends ApplicationAdapter implements EventListener {
	public static Editor instance;

	private EditorFrame frame;

	private Stage stage;
	private Table root;

	// TODO move to module
	private Table mainContentTable;
	private Table tabContentTable;
	private VisTable projectContentTable;
	private VisSplitPane splitPane;

	private ModuleContainer moduleContainer;
	private ProjectModuleContainer projectModuleContainer;

	private boolean projectLoaded = false;

	private StatusBarModule statusBar;

	private Tab tab;

	public Editor (EditorFrame frame) {
		this.frame = frame;
	}

	@Override
	public void create () {
		instance = this;
		Assets.load();
		VisUI.load();
		VisUI.setDefualtTitleAlign(Align.center);

		App.eventBus.register(this);

		stage = new Stage(new ScreenViewport());
		Gdx.input.setInputProcessor(stage);

		mainContentTable = new Table();
		tabContentTable = new Table();
		projectContentTable = new VisTable(true);
		splitPane = new VisSplitPane(null, null, true);
		splitPane.setSplitAmount(0.7f);

		projectContentTable.add(new VisLabel("Project Content Manager has not been loaded yet"));

		root = new Table();
		root.setFillParent(true);
		stage.addActor(root);

		moduleContainer = new ModuleContainer();
		projectModuleContainer = new ProjectModuleContainer(moduleContainer);

		moduleContainer.add(new ProjectIOModule());

		// GUI modules
		moduleContainer.add(new MenuBarModule(projectModuleContainer));
		moduleContainer.add(new ToolbarModule());
		moduleContainer.add(new TabsModule());

		root.add(mainContentTable).expand().fill().row();
		root.row();

		moduleContainer.add(new StatusBarModule());

		moduleContainer.init();

		// debug section
		try {
			moduleContainer.get(ProjectIOModule.class).load((new File("F:\\Poligon\\TestProject")));
		} catch (EditorException e) {
			e.printStackTrace();
		}
		
		EditorScene testScene = projectModuleContainer.get(SceneIOModule.class).load(Gdx.files.absolute("F:\\Poligon\\TestProject\\vis\\assets\\scene\\test.json"));
		projectModuleContainer.get(SceneTabsModule.class).open(testScene);
	}

	public StatusBarModule getStatusBar () {
		return statusBar;
	}

	@Override
	public void resize (int width, int height) {
		stage.getViewport().update(width, height, true);
		moduleContainer.resize();
		projectModuleContainer.resize();
	}

	@Override
	public void render () {
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		stage.act(Gdx.graphics.getDeltaTime());
		if (tab != null) tab.render(stage.getBatch());
{'fraction_non_alphanumeric': 0.10963488843813388, 'fraction_numerical': 0.002839756592292089, 'mean_word_length': 5.031192660550459, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5618728', 'n_tokens_mistral': 3258, 'n_tokens_neox': 3042, 'n_words': 686}