diff --git a/Java/scripts/build.sh b/Java/scripts/build.sh index a9eba68..b8a2bed 100755 --- a/Java/scripts/build.sh +++ b/Java/scripts/build.sh @@ -1,7 +1,8 @@ #Builds and runs the project. #Java +source ${LANGUAGE}/scripts/version_info rm -Rf out/* -javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java printf "\n\n\nRunning Program...\n\n" ORIGINAL_LOC=$(pwd) cd $OUT_DIR diff --git a/Java/scripts/commit.sh b/Java/scripts/commit.sh index 689cc0b..36b45b5 100755 --- a/Java/scripts/commit.sh +++ b/Java/scripts/commit.sh @@ -1,6 +1,7 @@ #Adds a commit message and pushes project to github repository. #Java COMMIT_MESSAGE="$*" +FIRST_LINE=true while IFS= read -r line do if [ "$FIRST_LINE" = true ]; then diff --git a/Java/scripts/filelist b/Java/scripts/filelist new file mode 100644 index 0000000..0ddba96 --- /dev/null +++ b/Java/scripts/filelist @@ -0,0 +1,5 @@ +build.sh +clean.sh +commit.sh +jar.sh +version_info diff --git a/Java/scripts/jar.sh b/Java/scripts/jar.sh index 532ab48..1d3fad6 100755 --- a/Java/scripts/jar.sh +++ b/Java/scripts/jar.sh @@ -1,7 +1,8 @@ #Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar. #Java +source ${LANGUAGE}/scripts/version_info rm -Rf bin/* -javac -Xlint:unchecked -cp src -d bin ${PROJECT_DIR}/${PROJECT_NAME}.java +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp src -d bin ${PROJECT_DIR}/${PROJECT_NAME}.java printf "\n\n\nGenerating Manifest...\n\n" touch manifest echo "Main-Class: ${MAIN_CLASS}" >> manifest diff --git a/Java/scripts/md5 b/Java/scripts/md5 index e1dbce1..d4665a7 100644 --- a/Java/scripts/md5 +++ b/Java/scripts/md5 @@ -1,4 +1,4 @@ -build.sh:377a432ffbd63b53322d1451a214201d - +build.sh:55f0208b07ba384f45009d6f92fe88fe - clean.sh:96ce35f2d2dcb555421e00a6afda23ca - -commit.sh:b186d649fa17c68926fe1caec4a7216c - -jar.sh:cce5e429168700490f9c413b665d13d6 - +commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - +jar.sh:56f9b7c6dc8e85f28ffefe9ce82b1f07 - diff --git a/Java/scripts/version_info b/Java/scripts/version_info new file mode 100644 index 0000000..51b7812 --- /dev/null +++ b/Java/scripts/version_info @@ -0,0 +1,2 @@ +export SOURCE_VERSION="1.8" +export TARGET_VERSION="1.8" \ No newline at end of file diff --git a/bin/JavaProjectTemplate.jar b/bin/JavaProjectTemplate.jar deleted file mode 100644 index 37133e2..0000000 Binary files a/bin/JavaProjectTemplate.jar and /dev/null differ diff --git a/bin/SigShare.jar b/bin/SigShare.jar new file mode 100644 index 0000000..ad402b0 Binary files /dev/null and b/bin/SigShare.jar differ diff --git a/sig b/sig index a659f7b..cf87e2c 100755 --- a/sig +++ b/sig @@ -1,6 +1,6 @@ source utils/define.sh -define PROJECT_NAME "JavaProjectTemplate" +define PROJECT_NAME "SigShare" define PROJECT_DIR "src/sig" define MAIN_CLASS "sig.${PROJECT_NAME}" define OUT_DIR "bin" diff --git a/src/sig/JavaProjectTemplate.java b/src/sig/JavaProjectTemplate.java deleted file mode 100644 index ac5ae34..0000000 --- a/src/sig/JavaProjectTemplate.java +++ /dev/null @@ -1,21 +0,0 @@ -package sig; - -import javax.swing.JFrame; -import sig.engine.Panel; - -public class JavaProjectTemplate { - public static final String PROGRAM_NAME="Sig's Java Project Template"; - public static void main(String[] args) { - JFrame f = new JFrame(PROGRAM_NAME); - Panel p = new Panel(f); - - p.init(); - - f.add(p); - f.setSize(1280,720); - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - f.setVisible(true); - - p.render(); - } -} diff --git a/src/sig/SigShare.java b/src/sig/SigShare.java new file mode 100644 index 0000000..7a65ccf --- /dev/null +++ b/src/sig/SigShare.java @@ -0,0 +1,86 @@ +package sig; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.regex.Pattern; + +import javax.swing.JFrame; +import java.awt.Toolkit; +import sig.engine.Panel; + +public class SigShare { + public static final String PROGRAM_NAME="SigShare"; + public static void main(String[] args) { + if (args.length==2&&args[1].equalsIgnoreCase("server")) { + ServerSocket socket; + try { + socket = new ServerSocket(4191); + System.out.println("Listening on port 4191."); + try (Socket client = socket.accept()) { + System.out.println("New client connection detected: "+client.toString()); + System.out.println("Sending initial data..."); + BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream(),"ISO-8859-1")); + OutputStream clientOutput = client.getOutputStream(); + int SCREEN_WIDTH=(int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + int SCREEN_HEIGHT=(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + clientOutput.write(("DESKTOP "+(int)Toolkit.getDefaultToolkit().getScreenSize().getWidth()+" "+(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()+"\r\n").getBytes()); + System.out.println("Send initial screen"); + for (int y=0;y server|client"); + return; + } + } +} diff --git a/src/sig/engine/Panel.java b/src/sig/engine/Panel.java index 2f558f7..caa9363 100644 --- a/src/sig/engine/Panel.java +++ b/src/sig/engine/Panel.java @@ -12,13 +12,11 @@ import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; -import sig.JavaProjectTemplate; +import sig.SigShare; public class Panel extends JPanel implements Runnable { JFrame window; public int pixel[]; - public int width=1280; - public int height=720; final int CIRCLE_PRECISION=32; final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); private Thread thread; @@ -55,14 +53,14 @@ public class Panel extends JPanel implements Runnable { */ public void init(){ cm = getCompatibleColorModel(); - int screenSize = width * height; + int screenSize = getWidth() * getHeight(); if(pixel == null || pixel.length < screenSize){ pixel = new int[screenSize]; } if(thread.isInterrupted() || !thread.isAlive()){ thread.start(); } - mImageProducer = new MemoryImageSource(width, height, cm, pixel,0, width); + mImageProducer = new MemoryImageSource(getWidth(), getHeight(), cm, pixel,0, getWidth()); mImageProducer.setAnimated(true); mImageProducer.setFullBufferUpdates(true); imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer); @@ -80,7 +78,7 @@ public class Panel extends JPanel implements Runnable { if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) { - window.setTitle(JavaProjectTemplate.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); + window.setTitle(SigShare.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); lastFrameCount=frameCount; lastSecond=System.currentTimeMillis(); } @@ -103,44 +101,12 @@ public class Panel extends JPanel implements Runnable { int[] p = pixel; // this avoid crash when resizing //a=h/w - for (int x=0;x=0) { Draw(p,index,col.getColor()); } @@ -308,7 +274,7 @@ public class Panel extends JPanel implements Runnable { // request a JPanel re-drawing repaint(); //System.out.println("Repaint "+frameCount++); - //try {Thread.sleep(1);} catch (InterruptedException e) {} + try {Thread.sleep(16);} catch (InterruptedException e) {} } } } \ No newline at end of file diff --git a/utils/define.sh b/utils/define.sh index 39a23d7..be5dbad 100755 --- a/utils/define.sh +++ b/utils/define.sh @@ -12,6 +12,7 @@ if [[ $(pwd) != *"SigScript" ]]; then source utils/search.sh find . -type f -name md5 -delete + find . -type f -name filelist -delete #Check for hashes FILES=$(cat utils/.updateDirectories) diff --git a/utils/filelist b/utils/filelist new file mode 100644 index 0000000..95ad5ff --- /dev/null +++ b/utils/filelist @@ -0,0 +1,5 @@ +.coauthors +define.sh +main.sh +search.sh +.updateDirectories diff --git a/utils/main.sh b/utils/main.sh index b04ffab..158326e 100644 --- a/utils/main.sh +++ b/utils/main.sh @@ -16,7 +16,7 @@ if [ -z "$1" ] FILES=$(ls -1A ./$LANGUAGE/scripts | sed -e 's/\.sh$//' | sed -e 's/^/ /') for f in $FILES do - if [ $f != "md5" ]; then + if [ $f != "md5" ] && [ $f != "version_info" ] && [ $f != "filelist" ]; then DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" printf "\n\t%-15s%-65s" $f "${DESC:1}" fi diff --git a/utils/md5 b/utils/md5 index 32d88fe..a47b4f9 100644 --- a/utils/md5 +++ b/utils/md5 @@ -1,5 +1,4 @@ -.coauthors:3785ad38663e5fc43e574914ad067294 - -define.sh:74ea08fb12cab1053663f87007ddd29a - -main.sh:eacf0984141d284db6681dee4dc39ffa - -search.sh:7162a8e3487a5cca5a3a24d55230e24d - +define.sh:883c4033be11b6d1268b852beada5463 - +main.sh:663ac9bb9ee46eb8cd1d717e8eb5e486 - +search.sh:2a471ffc3daa12f96157e613873f589d - .updateDirectories:0ede00461e947494545e694040787b3f - diff --git a/utils/search.sh b/utils/search.sh index 13307c4..73885b0 100644 --- a/utils/search.sh +++ b/utils/search.sh @@ -8,11 +8,14 @@ function search() { search $1$g/ else echo "$1$g is a file" - if [ $g != "md5" ]; then - SUM=$(md5sum < $1$g) - echo "$g:$SUM" >> $1md5 + if [ $g != "md5" ] && [ $g != "filelist" ]; then + if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then + SUM=$(md5sum < $1$g) + echo "$g:$SUM" >> $1md5 + fi + echo "$g" >> $1filelist else - echo " md5 file, ignoring..." + echo " ignoring $g..." fi fi done @@ -24,7 +27,7 @@ function check() { if [ -f "$1/md5" ]; then echo " md5: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" - curl -H 'Cache-Control: no-cache, no-store' -s https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5 --output /tmp/out + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" --output /tmp/out cmp -s $1/md5 /tmp/out if [ "$?" -ne 0 ] then @@ -35,21 +38,55 @@ function check() { IFS=':' read -ra split <<< $line g="${split[0]}" echo "LINE -- $g" - if [ "$g" != "md5" ]; then + if [ "$g" != "md5" ] && [ "$g" != "filelist" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + if [ -f "$1/filelist" ]; + then + echo " filelist: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" --output /tmp/out + cmp -s $1/filelist /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ]; then if [ -f $1$g ]; then - if [ "$g" != ".coauthors" ]; then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then echo "++Redownload $1$g..." if [ -f "$1$g" ]; then - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $1$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g else echo "===Could not find directory, assuming regular scripts directory exists." - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $LANGUAGE/scripts/$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g fi fi else echo "++==Downloading $1$g..." - curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $1$g + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g fi fi done < /tmp/out