Setup initial server and client
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e94bc0b309
commit
90ac96e9cb
@ -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
|
||||
|
@ -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
|
||||
|
5
Java/scripts/filelist
Normal file
5
Java/scripts/filelist
Normal file
@ -0,0 +1,5 @@
|
||||
build.sh
|
||||
clean.sh
|
||||
commit.sh
|
||||
jar.sh
|
||||
version_info
|
@ -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
|
||||
|
@ -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 -
|
||||
|
2
Java/scripts/version_info
Normal file
2
Java/scripts/version_info
Normal file
@ -0,0 +1,2 @@
|
||||
export SOURCE_VERSION="1.8"
|
||||
export TARGET_VERSION="1.8"
|
Binary file not shown.
BIN
bin/SigShare.jar
Normal file
BIN
bin/SigShare.jar
Normal file
Binary file not shown.
2
sig
2
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"
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
86
src/sig/SigShare.java
Normal file
86
src/sig/SigShare.java
Normal file
@ -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<SCREEN_HEIGHT;y++) {
|
||||
for (int x=0;x<SCREEN_WIDTH;x++) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else
|
||||
if (args.length==2&&args[1].equalsIgnoreCase("client")) {
|
||||
Socket socket;
|
||||
PrintWriter out;
|
||||
BufferedReader in;
|
||||
|
||||
JFrame f = new JFrame(PROGRAM_NAME);
|
||||
Panel p = new Panel(f);
|
||||
|
||||
try {
|
||||
socket = new Socket(args[0],4191);
|
||||
out = new PrintWriter(socket.getOutputStream(),true);
|
||||
in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
|
||||
while (true) {
|
||||
String line;
|
||||
if (in.ready()) {
|
||||
line=in.readLine();
|
||||
//System.out.println(line);
|
||||
if (line.contains("DESKTOP")) {
|
||||
String[] split = line.split(Pattern.quote(" "));
|
||||
|
||||
p.init();
|
||||
|
||||
f.add(p);
|
||||
f.setSize(Integer.parseInt(split[1]),Integer.parseInt(split[2]));
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setVisible(true);
|
||||
|
||||
p.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.err.println("Args: <Connecting IP Address> server|client");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<width;x++) {
|
||||
for (int y=0;y<height;y++) {
|
||||
p[y*width+x]=(0<<16)+(0<<8)+0;
|
||||
}
|
||||
}
|
||||
|
||||
x_offset+=1;
|
||||
y_offset=50;
|
||||
|
||||
FillPolygon(p,Color.WHITE,50,50,new Point[] {
|
||||
new Point(135,2),
|
||||
new Point(166,96),
|
||||
new Point(265,97),
|
||||
new Point(185,156),
|
||||
new Point(215,251),
|
||||
new Point(134,192),
|
||||
new Point(54,251),
|
||||
new Point(84,156),
|
||||
new Point(4,97),
|
||||
new Point(103,96),
|
||||
});
|
||||
FillPolygon(p,Color.BRIGHT_CYAN,x_offset,y_offset,new Point[] {
|
||||
new Point(28,29),
|
||||
new Point(78,103),
|
||||
new Point(120,31),
|
||||
new Point(123,221),
|
||||
new Point(30,218),
|
||||
});
|
||||
//FillRect(p,Color.BRIGHT_RED,200,200,600,64);
|
||||
final Color testAlpha = new Color(150,0,0,128);
|
||||
FillCircle(p,testAlpha,150,150,100);
|
||||
FillOval(p,Color.BRIGHT_GREEN,300,150,100,50);
|
||||
}
|
||||
|
||||
public void FillRect(int[] p,Color col,double x,double y,double w,double h) {
|
||||
for (int xx=0;xx<w;xx++) {
|
||||
for (int yy=0;yy<h;yy++) {
|
||||
int index = ((int)y+yy)*width+(int)x+xx;
|
||||
int index = ((int)y+yy)*getWidth()+(int)x+xx;
|
||||
p[index]=col.getColor();
|
||||
}
|
||||
}
|
||||
@ -213,7 +179,7 @@ public class Panel extends JPanel implements Runnable {
|
||||
Edge e2 = active_edges.get(i+1);
|
||||
//System.out.println("Drawing from "+((int)Math.round(e1.x_of_min_y))+" to "+e2.x_of_min_y+" on line "+scanLine);
|
||||
for (int x=(int)Math.round(e1.x_of_min_y);x<=e2.x_of_min_y;x++) {
|
||||
int index = (scanLine+(int)y_offset)*width+x+(int)x_offset;
|
||||
int index = (scanLine+(int)y_offset)*getWidth()+x+(int)x_offset;
|
||||
if (index<p.length&&index>=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) {}
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
5
utils/filelist
Normal file
5
utils/filelist
Normal file
@ -0,0 +1,5 @@
|
||||
.coauthors
|
||||
define.sh
|
||||
main.sh
|
||||
search.sh
|
||||
.updateDirectories
|
@ -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
|
||||
|
@ -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 -
|
||||
|
@ -8,11 +8,14 @@ function search() {
|
||||
search $1$g/
|
||||
else
|
||||
echo "$1$g is a file"
|
||||
if [ $g != "md5" ]; then
|
||||
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" ]; 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
|
||||
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" ] && [ "$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
|
||||
|
Loading…
x
Reference in New Issue
Block a user