commit
05c57aa798
@ -0,0 +1,9 @@ |
||||
#Builds and runs the project. |
||||
#Java |
||||
source ${LANGUAGE}/scripts/version_info |
||||
javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/*.java |
||||
printf "\n\n\nRunning Program...\n\n" |
||||
ORIGINAL_LOC=$(pwd) |
||||
cd $OUT_DIR |
||||
java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@" |
||||
${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh |
@ -0,0 +1,4 @@ |
||||
#Cleans up and removes unused files. |
||||
#Java |
||||
find -type f -name *.class -delete |
||||
find -type f -name manifest -delete |
@ -0,0 +1,20 @@ |
||||
#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 |
||||
COMMIT_MESSAGE+=" |
||||
|
||||
Co-authored-by: $line" |
||||
FIRST_LINE=false |
||||
else |
||||
COMMIT_MESSAGE+=" |
||||
Co-authored-by: $line" |
||||
fi |
||||
done < utils/.coauthors |
||||
git add -u |
||||
git add * |
||||
git commit -m "$COMMIT_MESSAGE" |
||||
git push |
@ -0,0 +1,7 @@ |
||||
build.sh |
||||
clean.sh |
||||
commit.sh |
||||
jar.sh |
||||
release.sh |
||||
update.sh |
||||
version_info |
@ -0,0 +1,17 @@ |
||||
#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 -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/${PROJECT_NAME}.java |
||||
printf "\n\n\nGenerating Manifest...\n\n" |
||||
touch manifest |
||||
echo "Main-Class: ${MAIN_CLASS}" >> manifest |
||||
printf "\n\n\nCreating Jar...\n\n" |
||||
ORIGINAL_LOC=$(pwd) |
||||
cd ${OUT_DIR} |
||||
jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig |
||||
jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ . |
||||
printf "\n\n\nRunning Program...\n\n" |
||||
java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" |
||||
../${LANGUAGE}/scripts/clean.sh |
||||
cd .. |
@ -0,0 +1,6 @@ |
||||
build.sh:22308eae5fd9c88aa16fef54cf03ae21 - |
||||
clean.sh:668a2f9b568c55f6a044a509315032f6 - |
||||
commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - |
||||
jar.sh:343cf505530401fb696296bc25a9b090 - |
||||
release.sh:b1b62203411b18d0fec1db3dc2e5a061 - |
||||
update.sh:3be721658983183efa395984acd96b03 - |
@ -0,0 +1,14 @@ |
||||
#Creates a zip file containing all project contents. |
||||
#Java |
||||
source ${LANGUAGE}/scripts/version_info |
||||
TARGET_FILE="${PROJECT_NAME}_${RELEASE_VERSION}.zip" |
||||
FILES=$(cat ${LANGUAGE}/scripts/.package.files) |
||||
echo "Creating Package $TARGET_FILE..." |
||||
for f in $FILES |
||||
do |
||||
zip -ur $TARGET_FILE $f |
||||
done |
||||
echo "Complete!" |
||||
echo "" |
||||
echo "" |
||||
echo "" |
@ -0,0 +1,3 @@ |
||||
#Pulls the latest version of the repository. |
||||
#Java |
||||
git pull |
@ -0,0 +1,3 @@ |
||||
export SOURCE_VERSION="8" |
||||
export TARGET_VERSION="8" |
||||
export RELEASE_VERSION="0.0a" |
@ -0,0 +1,27 @@ |
||||
# JavaProjectTemplate |
||||
Provides a Java pipeline for building applications and deploying a JAR with ease. Providing a base graphical engine (fast pixel blitting) with support for input should be enough to get any project going. |
||||
|
||||
The system will also use the SigScript updating system to keep files up-to-date. |
||||
|
||||
## Usage: |
||||
**./sig** - Shows a menu with all scripts. Example output: |
||||
``` |
||||
gitpod /workspace/JavaProjectTemplate (main) $ ./sig |
||||
|
||||
Usage: ./sig <command> {args} |
||||
|
||||
==== Current Configuration ===================== |
||||
PROJECT_NAME JavaProjectTemplate |
||||
PROJECT_DIR src/sig |
||||
MAIN_CLASS sig.JavaProjectTemplate |
||||
OUT_DIR bin |
||||
===================================================== |
||||
|
||||
Command List: |
||||
|
||||
build Builds and runs the project. |
||||
clean Cleans up and removes unused files. |
||||
commit Adds a commit message and pushes project to github repository. |
||||
jar Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar. |
||||
``` |
||||
Configuration is modified at the top of the script file while the command list includes all included modules inside of `scripts`. |
Binary file not shown.
@ -0,0 +1,11 @@ |
||||
export AUTO_UPDATE=true |
||||
|
||||
source utils/define.sh |
||||
|
||||
define PROJECT_NAME "JavaProjectTemplate" |
||||
define PROJECT_DIR "src/sig" |
||||
define MAIN_CLASS "sig.${PROJECT_NAME}" |
||||
define OUT_DIR "bin" |
||||
define LANGUAGE "Java" |
||||
|
||||
source utils/main.sh |
@ -0,0 +1,21 @@ |
||||
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(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
package sig.engine; |
||||
|
||||
public class Color { |
||||
int r,g,b,a; |
||||
|
||||
final static public Color BLACK = new Color(0,0,0); |
||||
final static public Color RED = new Color(204,0,0); |
||||
final static public Color GREEN = new Color(78,154,6); |
||||
final static public Color YELLOW = new Color(196,160,0); |
||||
final static public Color BLUE = new Color(114,159,207); |
||||
final static public Color MAGENTA = new Color(117,80,123); |
||||
final static public Color CYAN = new Color(6,152,154); |
||||
final static public Color WHITE = new Color(211,215,207); |
||||
final static public Color BRIGHT_BLACK = new Color(85,87,83); |
||||
final static public Color BRIGHT_RED = new Color(239,41,41); |
||||
final static public Color BRIGHT_GREEN = new Color(138,226,52); |
||||
final static public Color BRIGHT_YELLOW = new Color(252,233,79); |
||||
final static public Color BRIGHT_BLUE = new Color(50,175,255); |
||||
final static public Color BRIGHT_MAGENTA = new Color(173,127,168); |
||||
final static public Color BRIGHT_CYAN = new Color(52,226,226); |
||||
final static public Color BRIGHT_WHITE = new Color(255,255,255); |
||||
|
||||
public Color(int r, int g, int b) { |
||||
this(r,g,b,255); |
||||
} |
||||
|
||||
public Color(int r, int g, int b,int a) { |
||||
super(); |
||||
this.r = r; |
||||
this.g = g; |
||||
this.b = b; |
||||
this.a = a; |
||||
} |
||||
|
||||
public int getColor() { |
||||
return (a<<24)+(r<<16)+(g<<8)+b; |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
package sig.engine; |
||||
|
||||
public class Edge { |
||||
Point a,b; |
||||
int min_y; |
||||
int max_y; |
||||
int min_x; |
||||
int max_x; |
||||
double x_of_min_y; |
||||
double inverse_slope; |
||||
public Edge(Point a, Point b) { |
||||
super(); |
||||
this.a = a; |
||||
this.b = b; |
||||
min_y=Math.min(a.y, b.y); |
||||
max_y=Math.max(a.y, b.y); |
||||
min_x=Math.min(a.x, b.x); |
||||
max_x=Math.max(a.x, b.x); |
||||
if (a.y==min_y) { |
||||
x_of_min_y=a.x; |
||||
} else { |
||||
x_of_min_y=b.x; |
||||
} |
||||
|
||||
inverse_slope=(double)(a.x-b.x)/(a.y-b.y); |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "Edge [a=" + a + ", b=" + b + ", min_y=" + min_y + ", max_y=" + max_y + ", min_x=" + min_x + ", max_x=" |
||||
+ max_x + ", x_of_min_y=" + x_of_min_y + ", inverse_slope=" + inverse_slope + "]"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,314 @@ |
||||
package sig.engine; |
||||
import java.awt.Graphics; |
||||
import java.awt.GraphicsConfiguration; |
||||
import java.awt.GraphicsEnvironment; |
||||
import java.awt.Image; |
||||
import java.awt.Toolkit; |
||||
import java.awt.image.ColorModel; |
||||
import java.awt.image.MemoryImageSource; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
|
||||
import sig.JavaProjectTemplate; |
||||
|
||||
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; |
||||
private Image imageBuffer; |
||||
private MemoryImageSource mImageProducer; |
||||
private ColorModel cm; |
||||
int scanLine=0; |
||||
int nextScanLine=0; |
||||
double x_offset=0; |
||||
double y_offset=0; |
||||
int frameCount=0; |
||||
long lastSecond=0; |
||||
int lastFrameCount=0; |
||||
|
||||
public Panel(JFrame f) { |
||||
super(true); |
||||
this.window=f; |
||||
thread = new Thread(this, "MyPanel Thread"); |
||||
} |
||||
|
||||
/** |
||||
* Get Best Color model available for current screen. |
||||
* @return color model |
||||
*/ |
||||
protected static ColorModel getCompatibleColorModel(){ |
||||
GraphicsConfiguration gfx_config = GraphicsEnvironment. |
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice(). |
||||
getDefaultConfiguration(); |
||||
return gfx_config.getColorModel(); |
||||
} |
||||
|
||||
/** |
||||
* Call it after been visible and after resizes. |
||||
*/ |
||||
public void init(){ |
||||
cm = getCompatibleColorModel(); |
||||
int screenSize = width * height; |
||||
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.setAnimated(true); |
||||
mImageProducer.setFullBufferUpdates(true); |
||||
imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer); |
||||
} |
||||
|
||||
@Override |
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
// perform draws on pixels
|
||||
render(); |
||||
// ask ImageProducer to update image
|
||||
mImageProducer.newPixels(); |
||||
// draw it on panel
|
||||
g.drawImage(this.imageBuffer, 0, 0, this); |
||||
|
||||
|
||||
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) { |
||||
window.setTitle(JavaProjectTemplate.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); |
||||
lastFrameCount=frameCount; |
||||
lastSecond=System.currentTimeMillis(); |
||||
} |
||||
frameCount++; |
||||
} |
||||
|
||||
/** |
||||
* Overrides ImageObserver.imageUpdate. |
||||
* Always return true, assuming that imageBuffer is ready to go when called |
||||
*/ |
||||
@Override |
||||
public boolean imageUpdate(Image image, int a, int b, int c, int d, int e) { |
||||
return true; |
||||
} |
||||
/** |
||||
* Do your draws in here !! |
||||
* pixel is your canvas! |
||||
*/ |
||||
public /* abstract */ void render(){ |
||||
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; |
||||
p[index]=col.getColor(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void FillCircle(int[] p,Color col,double center_x,double center_y,double r) { |
||||
int counter=0; |
||||
Point[] points = new Point[CIRCLE_PRECISION]; |
||||
for (double theta=0;theta<Math.PI*2;theta+=((Math.PI*2)/CIRCLE_PRECISION)) { |
||||
//System.out.println("Loop "+counter+++". Theta:"+theta);
|
||||
//System.out.println("X:"+(Math.sin(theta)*r+center_x)+" Y:"+(Math.cos(theta)*r+center_y));
|
||||
points[counter++]=new Point((int)(Math.round(Math.sin(theta)*r+center_x)),(int)(Math.round(Math.cos(theta)*r+center_y))); |
||||
} |
||||
FillPolygon(p,col,0,0,points); |
||||
} |
||||
|
||||
|
||||
public void FillOval(int[] p,Color col,double center_x,double center_y,double w,double h) { |
||||
int counter=0; |
||||
Point[] points = new Point[CIRCLE_PRECISION]; |
||||
double r = Math.max(w,h); |
||||
double ratio = Math.min(w,h)/r; |
||||
for (double theta=0;theta<Math.PI*2;theta+=((Math.PI*2)/CIRCLE_PRECISION)) { |
||||
//System.out.println("Loop "+counter+++". Theta:"+theta);
|
||||
//System.out.println("X:"+(Math.sin(theta)*r+center_x)+" Y:"+(Math.cos(theta)*r+center_y));
|
||||
Point newP = new Point((int)(Math.round(Math.sin(theta)*r)),(int)(Math.round(Math.cos(theta)*r))); |
||||
if (w<h) { |
||||
newP.x=(int)Math.round(newP.x*ratio); |
||||
} else { |
||||
newP.y=(int)Math.round(newP.y*ratio); |
||||
} |
||||
newP.x+=center_x; |
||||
newP.y+=center_y; |
||||
points[counter++]=newP; |
||||
} |
||||
FillPolygon(p,col,0,0,points); |
||||
} |
||||
|
||||
public void FillPolygon(int[] p,Color col,double x_offset,double y_offset,Point...points) { |
||||
Edge[] edges = new Edge[points.length]; |
||||
List<Edge> edges_sorted = new ArrayList<Edge>(); |
||||
for (int i=0;i<points.length;i++) { |
||||
edges[i] = new Edge(points[i],points[(i+1)%points.length]); |
||||
if (!Double.isInfinite(edges[i].inverse_slope)) { |
||||
if (edges_sorted.size()==0) { |
||||
edges_sorted.add(edges[i]); |
||||
} else { |
||||
boolean inserted=false; |
||||
for (int j=0;j<edges_sorted.size();j++) { |
||||
Edge e2 = edges_sorted.get(j); |
||||
if (e2.min_y>=edges[i].min_y) { |
||||
edges_sorted.add(j,edges[i]); |
||||
inserted=true; |
||||
break; |
||||
} |
||||
} |
||||
if (!inserted) { |
||||
edges_sorted.add(edges[i]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
//System.out.println(edges_sorted);
|
||||
List<Edge> active_edges = new ArrayList<Edge>(); |
||||
scanLine = edges_sorted.get(0).min_y-1; |
||||
nextScanLine = scanLine+1; |
||||
do { |
||||
for (int i=0;i<active_edges.size();i+=2) { |
||||
Edge e1 = active_edges.get(i); |
||||
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; |
||||
if (index<p.length&&index>=0) { |
||||
Draw(p,index,col.getColor()); |
||||
} |
||||
} |
||||
} |
||||
List<Edge> new_active_edges = new ArrayList<Edge>(); |
||||
for (int i=0;i<active_edges.size();i++) { |
||||
Edge e = active_edges.get(i); |
||||
if (e.max_y==scanLine+1) { |
||||
active_edges.remove(i--); |
||||
} else { |
||||
e.x_of_min_y+=e.inverse_slope; |
||||
} |
||||
} |
||||
scanLine++; |
||||
for (int i=0;i<active_edges.size();i++) { |
||||
Edge e = active_edges.get(i); |
||||
boolean inserted=false; |
||||
for (int j=0;j<new_active_edges.size();j++) { |
||||
Edge e2 = new_active_edges.get(j); |
||||
if (e2.x_of_min_y>e.x_of_min_y) { |
||||
new_active_edges.add(j,e); |
||||
inserted=true; |
||||
break; |
||||
} |
||||
} |
||||
if (!inserted) { |
||||
new_active_edges.add(e); |
||||
} |
||||
} |
||||
active_edges=new_active_edges; |
||||
GetNextScanLineEdges(edges_sorted, active_edges); |
||||
} |
||||
while (active_edges.size()>0); |
||||
} |
||||
|
||||
private void GetNextScanLineEdges(List<Edge> edges_sorted, List<Edge> active_edges) { |
||||
if (scanLine==nextScanLine) { |
||||
for (int i=0;i<edges_sorted.size();i++) { |
||||
Edge e = edges_sorted.get(i); |
||||
if (e.min_y==scanLine) { |
||||
e = edges_sorted.remove(i--); |
||||
boolean inserted=false; |
||||
for (int j=0;j<active_edges.size();j++) { |
||||
if (e.x_of_min_y<active_edges.get(j).x_of_min_y) { |
||||
active_edges.add(j,e); |
||||
inserted=true; |
||||
break; |
||||
} |
||||
} |
||||
if (!inserted) { |
||||
active_edges.add(e); |
||||
} |
||||
|
||||
} else |
||||
if (e.min_y>scanLine) { |
||||
nextScanLine=e.min_y; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void Draw(int[] canvas,int index, int col) { |
||||
int alpha = col>>>24; |
||||
if (alpha==0) { |
||||
return;} |
||||
else |
||||
if (alpha==255) { |
||||
canvas[index]=col; |
||||
} else { |
||||
float ratio=alpha/255f; |
||||
int prev_col=canvas[index]; |
||||
int prev_r=(prev_col&0xFF); |
||||
int prev_g=(prev_col&0xFF00)>>>8; |
||||
int prev_b=(prev_col&0xFF0000)>>>16; |
||||
int r=(col&0xFF); |
||||
int g=(col&0xFF00)>>>8; |
||||
int b=(col&0xFF0000)>>>16; |
||||
|
||||
int new_r=(int)(ratio*r+(1-ratio)*prev_r); |
||||
int new_g=(int)(ratio*g+(1-ratio)*prev_g); |
||||
int new_b=(int)(ratio*b+(1-ratio)*prev_b); |
||||
|
||||
canvas[index]=new_r+(new_g<<8)+(new_b<<16)+(col&0xFF000000); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
while (true) { |
||||
// request a JPanel re-drawing
|
||||
repaint(); |
||||
//System.out.println("Repaint "+frameCount++);
|
||||
//try {Thread.sleep(1);} catch (InterruptedException e) {}
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@ |
||||
package sig.engine; |
||||
|
||||
public class Point { |
||||
int x,y; |
||||
|
||||
public Point(int x, int y) { |
||||
super(); |
||||
this.x = x; |
||||
this.y = y; |
||||
} |
||||
|
||||
public int getX() { |
||||
return x; |
||||
} |
||||
|
||||
public void setX(int x) { |
||||
this.x = x; |
||||
} |
||||
|
||||
public int getY() { |
||||
return y; |
||||
} |
||||
|
||||
public void setY(int y) { |
||||
this.y = y; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "Point(" + x + "," + y + ")"; |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
.coauthors:3785ad38663e5fc43e574914ad067294 - |
||||
define.sh:d6b20a25a04a60d94f466e48fa60ac69 - |
||||
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 - |
||||
search.sh:3321258db3b59d8e4cfe04c472516e45 - |
||||
.updateDirectories:0ede00461e947494545e694040787b3f - |
||||
commit.sh:9c342703d765cad7ea296f16d68f29f4 - |
||||
.coauthors:3785ad38663e5fc43e574914ad067294 - |
||||
define.sh:d6b20a25a04a60d94f466e48fa60ac69 - |
||||
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 - |
||||
search.sh:3321258db3b59d8e4cfe04c472516e45 - |
||||
.updateDirectories:0ede00461e947494545e694040787b3f - |
@ -0,0 +1 @@ |
||||
sigonasr2 <sigonasr2@gmail.com> |
@ -0,0 +1,3 @@ |
||||
Java/ |
||||
scripts/ |
||||
utils/ |
@ -0,0 +1,26 @@ |
||||
export VARS=("") |
||||
|
||||
export LANGUAGE="" |
||||
|
||||
function define() { |
||||
VARS+=("$1") |
||||
value="${*:2}" |
||||
eval export "$1"='$value' |
||||
} |
||||
|
||||
if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then |
||||
source utils/search.sh |
||||
|
||||
find . -type f -name md5 -delete |
||||
find . -type f -name filelist -delete |
||||
|
||||
#Check for hashes |
||||
FILES=$(cat utils/.updateDirectories) |
||||
for f in $FILES |
||||
do |
||||
search $f |
||||
check $f |
||||
done |
||||
else |
||||
echo "Dev build, no checks required." |
||||
fi |
@ -0,0 +1,5 @@ |
||||
.coauthors |
||||
define.sh |
||||
main.sh |
||||
search.sh |
||||
.updateDirectories |
@ -0,0 +1,28 @@ |
||||
if [ -z "$1" ] |
||||
then |
||||
echo "" |
||||
echo " Usage: ./sig <command> {args}" |
||||
echo "" |
||||
printf "====\tCurrent Configuration" |
||||
printf "\t=====================" |
||||
for t in ${VARS[@]} |
||||
do |
||||
printf "\n\t%-15s%20s" $t ${!t} |
||||
done |
||||
printf "\n=====================================================" |
||||
echo "" |
||||
echo "" |
||||
echo " Command List:" |
||||
FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /') |
||||
for f in $FILES |
||||
do |
||||
if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then |
||||
DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" |
||||
printf "\n\t%-15s%-65s" $f "${DESC:1}" |
||||
fi |
||||
done |
||||
echo "" |
||||
exit |
||||
fi |
||||
|
||||
./$LANGUAGE/scripts/$1.sh "${*:2}" |
@ -0,0 +1,4 @@ |
||||
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - |
||||
main.sh:d3d1bd0b56d8114eb7479964227f8576 - |
||||
search.sh:81d08f5ff48e8a44b5f68387d426da05 - |
||||
.updateDirectories:0ede00461e947494545e694040787b3f - |
@ -0,0 +1,103 @@ |
||||
function search() { |
||||
FILES2=$(ls -A $1 2>/dev/null) |
||||
for g in $FILES2 |
||||
do |
||||
if [ -d $1$g ]; |
||||
then |
||||
echo "$1$g is a directory" |
||||
search $1$g/ |
||||
else |
||||
echo "$1$g is a file" |
||||
if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then |
||||
if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then |
||||
SUM=$(md5sum < $1$g) |
||||
echo "$g:$SUM" >> $1md5 |
||||
fi |
||||
echo "$g" >> $1filelist |
||||
else |
||||
echo " ignoring $g..." |
||||
fi |
||||
fi |
||||
done |
||||
} |
||||
|
||||
function check() { |
||||
echo "Check $1" |
||||
FILES2=$(ls -A $1 2>/dev/null) |
||||
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 |
||||
cmp -s $1/md5 /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" ] && [ "$g" != ".package.files" ]; 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" ] && [ "$g" != ".package.files" ]; 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 |
||||
for g in $FILES2 |
||||
do |
||||
if [ -d $1$g ]; |
||||
then |
||||
echo "$1$g is a directory" |
||||
check $1$g/ |
||||
fi |
||||
done |
||||
} |
Loading…
Reference in new issue