gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/GdxStudio.java
| a9b2a64 | 1 | package gdxstudio; |
| a9b2a64 | 2 | import gdxstudio.panel.ConsolePanel; |
| a9b2a64 | 3 | import gdxstudio.panel.StudioPanel; |
| a9b2a64 | 4 | |
| a62d533 | 5 | import java.awt.AlphaComposite; |
| a62d533 | 6 | import java.awt.Color; |
| a62d533 | 7 | import java.awt.Dimension; |
| a62d533 | 8 | import java.awt.Font; |
| a62d533 | 9 | import java.awt.Graphics2D; |
| a62d533 | 10 | import java.awt.SplashScreen; |
| a62d533 | 11 | import java.awt.Toolkit; |
| a62d533 | 12 | |
| a62d533 | 13 | import javax.swing.JFrame; |
| a62d533 | 14 | import javax.swing.SwingUtilities; |
| a62d533 | 15 | import javax.swing.UIManager; |
| a62d533 | 16 | |
| a9b2a64 | 17 | import scene2d.Asset; |
| a62d533 | 18 | import web.laf.lite.widget.Register; |
| a62d533 | 19 | |
| a9b2a64 | 20 | public class GdxStudio {
|
| a62d533 | 21 | public static final String version = "0.7.1"; |
| a62d533 | 22 | |
| a62d533 | 23 | public static void main(String[] args) {
|
| a62d533 | 24 | /*try {
|
| a62d533 | 25 | JavaLexer lexer = new JavaLexer(new ANTLRFileStream("C:/JavaParser.java"));
|
| a62d533 | 26 | JavaParser parser = new JavaParser(new CommonTokenStream(lexer)); |
| a62d533 | 27 | parser.addErrorListener(new DiagnosticErrorListener()); |
| a62d533 | 28 | parser.setErrorHandler(new DefaultErrorStrategy()); |
| a62d533 | 29 | parser.getInterpreter().setPredictionMode(PredictionMode.SLL); |
| a62d533 | 30 | parser.compilationUnit(); |
| a62d533 | 31 | } catch (IOException e) {
|
| a62d533 | 32 | e.printStackTrace(); |
| a62d533 | 33 | }*/ |
| a62d533 | 34 | SwingUtilities.invokeLater(new Runnable() {
|
| a62d533 | 35 | @Override |
| a62d533 | 36 | public void run() {
|
| a62d533 | 37 | Register.init("gdxstudio");
|
| a62d533 | 38 | Content.initProjects(); |
| a62d533 | 39 | try{
|
| a62d533 | 40 | UIManager.setLookAndFeel("web.laf.lite.ui.WebLookAndFeelLite");
|
| a62d533 | 41 | } |
| a62d533 | 42 | catch (Throwable e){
|
| a62d533 | 43 | e.printStackTrace (); |
| a62d533 | 44 | } |
| a62d533 | 45 | createSplash(); |
| a62d533 | 46 | //Frame.getInstance().pack(); |
| a62d533 | 47 | Frame.getInstance().setVisible(true); |
| a62d533 | 48 | Frame.getInstance().setExtendedState(JFrame.MAXIMIZED_BOTH); |
| a62d533 | 49 | ConsolePanel.redirectSystemStreams(); |
| a62d533 | 50 | if(Content.projectExists()){
|
| a62d533 | 51 | Asset.loadAsynchronous = false; |
| a62d533 | 52 | Asset.setBasePath(Content.getProject()); |
| a62d533 | 53 | SceneEditor.reloadAssets = true; // to load assets of new project |
| a62d533 | 54 | StudioPanel.updateAssets(); |
| a62d533 | 55 | Content.toggleView(2); |
| a62d533 | 56 | } |
| a62d533 | 57 | else{
|
| a62d533 | 58 | Frame.setDisabledProject(); |
| a62d533 | 59 | } |
| a62d533 | 60 | } |
| a62d533 | 61 | }); |
| a62d533 | 62 | /*SwingUtilities.invokeLater(new Runnable() {
|
| a62d533 | 63 | @Override |
| a62d533 | 64 | public void run() {
|
| a62d533 | 65 | new Update().setVisible(true); |
| a62d533 | 66 | } |
| a62d533 | 67 | });*/ |
| a62d533 | 68 | } |
| a62d533 | 69 | |
| a62d533 | 70 | static void createFrameWithoutSplash(){
|
| a62d533 | 71 | Icon.loadIcons(); |
| a62d533 | 72 | Frame.getInstance().setIconImage(Icon.icon("icon").getImage());
|
| a62d533 | 73 | Frame.getInstance().setTitle("GdxStudio");
|
| a62d533 | 74 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| a62d533 | 75 | Frame.getInstance().setSize(screenSize); |
| a62d533 | 76 | Frame.getInstance().setLocation(0, 0); |
| a62d533 | 77 | Frame.getInstance().setLocationRelativeTo(null); |
| a62d533 | 78 | Frame.getInstance().initSideBar(); |
| a62d533 | 79 | Frame.getInstance().initStatusBar(); |
| a62d533 | 80 | Frame.getInstance().initContent(); |
| a62d533 | 81 | Frame.getInstance().initToolBar(); |
| a62d533 | 82 | } |
| a62d533 | 83 | |
| a62d533 | 84 | static void createSplash(){
|
| a62d533 | 85 | Graphics2D g = null; |
| a62d533 | 86 | final SplashScreen splash = SplashScreen.getSplashScreen(); |
| a62d533 | 87 | if (splash == null) createFrameWithoutSplash(); |
| a62d533 | 88 | else {
|
| a62d533 | 89 | g = splash.createGraphics(); |
| a62d533 | 90 | renderSplashFrame(g, 1, "Initializing"); |
| a62d533 | 91 | splash.update(); |
| a62d533 | 92 | renderSplashFrame(g, 2, "Loading Icons"); |
| a62d533 | 93 | splash.update(); |
| a62d533 | 94 | Icon.loadIcons(); |
| a62d533 | 95 | renderSplashFrame(g, 3, "Loading Frame"); |
| a62d533 | 96 | splash.update(); |
| a62d533 | 97 | Frame.getInstance().setIconImage(Icon.icon("icon").getImage());
|
| a62d533 | 98 | Frame.getInstance().setTitle("GdxStudio");
|
| a62d533 | 99 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| a62d533 | 100 | Frame.getInstance().setSize(screenSize); |
| a62d533 | 101 | Frame.getInstance().setLocation(0, 0); |
| a62d533 | 102 | Frame.getInstance().setLocationRelativeTo(null); |
| a62d533 | 103 | renderSplashFrame(g, 4, "Loading Explorer"); |
| a62d533 | 104 | splash.update(); |
| a62d533 | 105 | renderSplashFrame(g, 5, "Loading SideBar"); |
| a62d533 | 106 | splash.update(); |
| a62d533 | 107 | Frame.getInstance().initSideBar(); |
| a62d533 | 108 | renderSplashFrame(g, 6, "Loading Status Bar"); |
| a62d533 | 109 | splash.update(); |
| a62d533 | 110 | Frame.getInstance().initStatusBar(); |
| a62d533 | 111 | renderSplashFrame(g, 7, "Loading Content"); |
| a62d533 | 112 | splash.update(); |
| a62d533 | 113 | Frame.getInstance().initContent(); |
| a62d533 | 114 | renderSplashFrame(g, 8, "Loading ToolBar"); |
| a62d533 | 115 | splash.update(); |
| a62d533 | 116 | Frame.getInstance().initToolBar(); |
| a62d533 | 117 | renderSplashFrame(g, 9, "Finished"); |
| a62d533 | 118 | splash.update(); |
| a62d533 | 119 | } |
| a62d533 | 120 | } |
| a62d533 | 121 | |
| a62d533 | 122 | static int height = 200; |
| a62d533 | 123 | static int width = 400; |
| a62d533 | 124 | static int fontHeight = 12; |
| a62d533 | 125 | private static int ind = 8; |
| a62d533 | 126 | |
| a62d533 | 127 | static void renderSplashFrame(Graphics2D g, int frame, String content) {
|
| a62d533 | 128 | g.setComposite(AlphaComposite.Src); |
| a62d533 | 129 | g.setColor(Color.BLACK); |
| a62d533 | 130 | g.setPaintMode(); |
| a62d533 | 131 | g.fillRect(0, height - 29, width, 17); |
| a62d533 | 132 | g.setColor(Color.RED); |
| a62d533 | 133 | ind--; |
| a62d533 | 134 | if(ind == 0) ind = 1; |
| a62d533 | 135 | for(int i= 0; i < frame; i ++) |
| a62d533 | 136 | for(int j= 0; j < i*frame/ind; j ++){
|
| a62d533 | 137 | int x = 9 *j; |
| a62d533 | 138 | /*if(x > 0 || x < 0) g.setColor(Color.RED); |
| a62d533 | 139 | if(x > width/4) g.setColor(Color.ORANGE); |
| a62d533 | 140 | if(x > width/2) g.setColor(Color.YELLOW); |
| a62d533 | 141 | if(x > 3*width/4) g.setColor(Color.GREEN);*/ |
| a62d533 | 142 | g.fillRect(x , height - 28, 8, 8); |
| a62d533 | 143 | } |
| a62d533 | 144 | g.setColor(Color.ORANGE); |
| a62d533 | 145 | for(int i= 0; i < frame; i ++) |
| a62d533 | 146 | for(int j= 0; j < i*frame/1.1; j ++) |
| a62d533 | 147 | g.fillRect(9 * j , height - 20, 8, 8); |
| a62d533 | 148 | |
| a62d533 | 149 | g.setColor(Color.BLACK); |
| a62d533 | 150 | g.fillRect(0, height - 12, width, fontHeight); |
| a62d533 | 151 | g.setColor(Color.WHITE); |
| a62d533 | 152 | g.setFont(new Font("Purisa", Font.PLAIN, 13));
|
| a62d533 | 153 | g.drawString(content, 0, height - 2); |
| a62d533 | 154 | } |
| a62d533 | 155 | |
| a62d533 | 156 | public static void log(String text){
|
| a62d533 | 157 | System.out.println(text); |
| a62d533 | 158 | } |
| a62d533 | 159 | |
| a62d533 | 160 | public static void error(String text){
|
| a62d533 | 161 | System.err.println(text); |
| a62d533 | 162 | } |
| a62d533 | 163 | } |