From 74a88f882ea83593d727e7031e20791349c013cd Mon Sep 17 00:00:00 2001 From: Przemyslaw Date: Mon, 1 Apr 2024 09:10:43 +0200 Subject: Init --- CzytajTo.docx | Bin 0 -> 4892 bytes Jttt.desktop | 14 + Jttt.png | Bin 0 -> 7136 bytes build.xml | 25 ++ makefile | 19 ++ src/Jttt.java | 605 ++++++++++++++++++++++++++++++++++++++++ wrapper-icon/Jttt.rc | 1 + wrapper-icon/Makefile.old.win | 33 +++ wrapper-icon/Makefile.win | 36 +++ wrapper-icon/config.txt | 1 + wrapper-icon/icon/Jttt.ico | Bin 0 -> 2686 bytes wrapper-icon/icon/Trefle.ico | Bin 0 -> 47826 bytes wrapper-icon/icon/ufo-small.ico | Bin 0 -> 2190 bytes wrapper-icon/wrapper.c | 71 +++++ 14 files changed, 805 insertions(+) create mode 100644 CzytajTo.docx create mode 100644 Jttt.desktop create mode 100644 Jttt.png create mode 100644 build.xml create mode 100644 makefile create mode 100644 src/Jttt.java create mode 100644 wrapper-icon/Jttt.rc create mode 100644 wrapper-icon/Makefile.old.win create mode 100644 wrapper-icon/Makefile.win create mode 100644 wrapper-icon/config.txt create mode 100644 wrapper-icon/icon/Jttt.ico create mode 100644 wrapper-icon/icon/Trefle.ico create mode 100644 wrapper-icon/icon/ufo-small.ico create mode 100644 wrapper-icon/wrapper.c diff --git a/CzytajTo.docx b/CzytajTo.docx new file mode 100644 index 0000000..dfd705b Binary files /dev/null and b/CzytajTo.docx differ diff --git a/Jttt.desktop b/Jttt.desktop new file mode 100644 index 0000000..077fd33 --- /dev/null +++ b/Jttt.desktop @@ -0,0 +1,14 @@ +#!/usr/bin/env xdg-open + +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Categories=Gnome;Games; + +Name=Tic Tac Toe + +Exec=java -jar /usr/bin/Jttt.jar +Terminal=false +Icon=/usr/share/jttt/Jttt.png + +Name[pl_PL]=Kółko i Krzyżyk diff --git a/Jttt.png b/Jttt.png new file mode 100644 index 0000000..8ad3776 Binary files /dev/null and b/Jttt.png differ diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..db4651a --- /dev/null +++ b/build.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/makefile b/makefile new file mode 100644 index 0000000..8242eef --- /dev/null +++ b/makefile @@ -0,0 +1,19 @@ +# Link command: +#choinka: engin.o +# gcc engin.o -o choinka + +# Compilation commands: +#engin.o: engin.c +# gcc -c engin.c -o engin.o + + +prefix=/usr/local + +install: build/jar/Jttt.jar + install -m 0755 build/jar/Jttt.jar $(prefix)/games + mkdir -pm 0777 $(prefix)/share/jttt + mkdir -pm 0777 $(prefix)/share/jttt/icons + install -m 0755 jttt.png $(prefix)/share/jttt/icons + install -m 0755 Jttt.desktop /usr/share/applications + +.PHONY: install diff --git a/src/Jttt.java b/src/Jttt.java new file mode 100644 index 0000000..6a289fb --- /dev/null +++ b/src/Jttt.java @@ -0,0 +1,605 @@ + + +//package Jttt; + +/* + * Lipiec 2019 + */ + +import java.awt.*; // Toolkit +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JMenuBar; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.Box; + +//import java.awt.Toolkit; +//import java.awt.BorderLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.util.Timer; +import java.util.*; //Timer + +public class Jttt extends JPanel + implements ActionListener { + static JButton [][]button = new JButton[3][3]; + String sbutton = "MyButton"; + static FieldGame[][]field = new FieldGame[3][3]; + static WhoseQueue whosequeue = WhoseQueue.CROSS; + static JLabel label = new JLabel("Ruch KRZYZA"); + static boolean action = true; + static int nmove=0; + static JMenuBar menuBar; + JMenu menu, info; + JMenuItem menuItem, menuExit, menuInfo; + static JFrame frame; + static Timer timer; + static boolean ai=false; + static boolean firstMoveAi=true; + + public enum WhoseQueue { + CROSS, WHELL + } + public enum FieldGame { + CROSS, WHELL, FREE + } + + + public Jttt() { + super(new GridBagLayout()); + GridBagLayout gridbag = (GridBagLayout)getLayout(); + GridBagConstraints c = new GridBagConstraints(); + int k=0; + + for (int i=0; i<3; i++) { + for(int j=0; j<3; j++) { + field[i][j]=FieldGame.FREE; + } + } + + menuBar = new JMenuBar(); + menu = new JMenu("Plik"); + menuBar.add(menu); + // przenosi INFO na prawa strone + menuBar.add(Box.createHorizontalGlue()); + info = new JMenu("Info"); + // kierunek wyswietlania menu + info.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + menuBar.add(info); + menuItem = new JMenuItem("Nowa Gra vs. HUMAN", null); + menuItem.setActionCommand("MenuItem1"); + menuItem.addActionListener(this); + menuItem.setToolTipText("Rozpoczyna nowa gre pomiedzy dwoma graczami."); + menu.add(menuItem); + menuItem = new JMenuItem("Nowa Gra vs. CPU", null); + menuItem.setActionCommand("MenuItem11"); + menuItem.addActionListener(this); + menuItem.setToolTipText("Rozpoczyna nowa gre pomiedzy komputerem \"X\" a graczem \"O\""); + menu.add(menuItem); + menu.addSeparator(); + menuExit = new JMenuItem("Zakoncz", null); + menuExit.setActionCommand("MenuItem2"); + menuExit.addActionListener(this); + menuExit.setToolTipText("Wyjscie z programu"); + menu.add(menuExit); + menuInfo = new JMenuItem("O Programie", null); + menuInfo.setActionCommand("MenuItem3"); + menuInfo.addActionListener(this); + menuInfo.setToolTipText("Informacje o programie"); + info.add(menuInfo); + + + for (int i=0; i<3; i++) { + for (int j=0; j<3; j++, k++) { + button[i][j] = new JButton("?"); + button[i][j].setPreferredSize(new Dimension(80, 80)); + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = j; + c.gridy = i; + gridbag.setConstraints(button[i][j], c); + //add(button0, BorderLayout.CENTER); + add(button[i][j]); + button[i][j].setActionCommand(sbutton+k); + button[i][j].addActionListener(this); + button[i][j].setFont(new Font("Arial", Font.PLAIN, 40)); + //button[i][j].setFont(new Font("Courier", Font.PLAIN, 40)); + } + } + label.setPreferredSize(new Dimension(100, 20)); + c.fill = GridBagConstraints.HORIZONTAL; + c.gridwidth = 3; + c.gridx = 0; + c.gridy = 3; + gridbag.setConstraints(label, c); + add(label); + + + } + + public void actionPerformed(ActionEvent e) { + + int k=0; + for(int i=0; i<3; i++) { + for(int j=0; j<3; j++, k++){ + if(e.getActionCommand().equals(sbutton+k) && action && nmove<9) + { + if(field[i][j].equals(FieldGame.FREE)) { + if (whosequeue.equals(WhoseQueue.CROSS) && !ai) { + Toolkit.getDefaultToolkit().beep(); + nmove++; + button[i][j].setText("X"); + field[i][j]=FieldGame.CROSS; + // powinno byc WhoseQueue.CROSS + // czy wygrana + if (win(FieldGame.CROSS)) { + label.setText("Wygral KRZYZ"); + action=false; + //System.out.println("pierwszy-KRZYZ"); + } + // to moze remis + else if (nmove==9) { + label.setText("Remis"); + action=false; + //System.out.println("+REMIS nmove:"+nmove); + } + //w przeciwnym wypadku ruch kolejnego gracza + else { + whosequeue=WhoseQueue.WHELL; + label.setText("Ruch KOLA"); + } + //System.out.println("KRZYZ nmove:"+nmove); + } + else if (whosequeue.equals(WhoseQueue.WHELL)) { + Toolkit.getDefaultToolkit().beep(); + nmove++; + button[i][j].setText("O"); + field[i][j]=FieldGame.WHELL; + // powinno byc WhoseQueue.WHELL + // czy wygrana + if (win(FieldGame.WHELL)) { + label.setText("Wygral KOLO"); + action=false; + //System.out.println("pierwszy-KOLO"); + } + // to moze remis + else if (nmove==9) { + label.setText("Remis"); + action=false; + //System.out.println("-REMIS nmove:"+nmove); + } + // w przeciwnym wypadku ruch kolejengo gracza + else { + whosequeue=WhoseQueue.CROSS; + label.setText("Ruch KRZYZA"); + } + // System.out.println("KOLO nmove:"+nmove); + } + } + } + } + } + // Nowa gra + if(e.getActionCommand().equals("MenuItem1")) { + for (int i=0; i<3; i++) { + for(int j=0; j<3; j++) { + field[i][j]=FieldGame.FREE; + button[i][j].setText("?"); + } + } + nmove=0; + action=true; + ai=false; + if (whosequeue.equals(WhoseQueue.CROSS)) { + label.setText("Ruch KRZYZA"); + } + else label.setText("Ruch KOLA"); + } + // Zakonczenie + else if(e.getActionCommand().equals("MenuItem2")) { + System.exit(0); + } + // O Programie + else if(e.getActionCommand().equals("MenuItem3")) { + + JOptionPane.showMessageDialog(frame, + "Moja pierwsza aplikacja\nstworzona w systemie Windows 10\nPrzemyslaw R. Pietraszczyk\nStworzono w oparciu o OpenJDK\nLipiec 2019", + "Jttt 0.210503-0", + JOptionPane.PLAIN_MESSAGE); + + } + // gra z komputerem + else if(e.getActionCommand().equals("MenuItem11")) { + for (int i=0; i<3; i++) { + for(int j=0; j<3; j++) { + field[i][j]=FieldGame.FREE; + button[i][j].setText("?"); + } + } + nmove=0; + action=true; + ai=true; + firstMoveAi=true; + if (whosequeue.equals(WhoseQueue.CROSS)) { + label.setText("Ruch KRZYZA"); + } + else label.setText("Ruch KOLA"); + } + } + //private boolean win (WhoseQueue wq) { + static private boolean win (FieldGame wq) { + + int accumulation=0; + // sprawdza w poziomie + for (int j=0; j<3; j++) { + for (int i=0; i<3; i++) { + if (field[j][i].equals(wq)) accumulation++; + } + if (accumulation==3) { + //wygral wq + return true; + } + accumulation=0; + } + // sprawdza w pionie + for (int j=0; j<3; j++) { + for (int i=0; i<3; i++) { + if (field[i][j].equals(wq)) accumulation++; + } + if (accumulation==3) { + //wygral wq + return true; + } + accumulation=0; + } + if (field[0][0].equals(wq) && field[1][1].equals(wq) && field[2][2].equals(wq)) { + // wygral wq + return true; + } + else if (field[0][2].equals(wq) && field[1][1].equals(wq) && field[2][0].equals(wq)){ + //wygral wq + return true; + } + return false; + } + + /** + * Create the GUI and show it. For thread safety, + * this method should be invoked from the + * event-dispatching thread. + */ + private static void createAndShowGUI() { + //Create and set up the window. + //JFrame frame = new JFrame("Jtic"); + frame = new JFrame("Jtictactoe"); + timer = new Timer(); + int frameWidth = 260; + int frameHeight = 380; + // ustawia okno po prawe na dole + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + frame.setBounds((int) screenSize.getWidth() - frameWidth, + (int) screenSize.getHeight() - frameHeight, frameWidth, frameHeight); + frame.setResizable(false); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + //Create and set up the content pane. + JComponent newContentPane = new Jttt(); + newContentPane.setOpaque(true); //content panes must be opaque + frame.setJMenuBar(menuBar); + frame.setContentPane(newContentPane); + + + //Display the window. + frame.pack(); + frame.setVisible(true); + + timer.schedule(new CheckAiMove(), 0, 5000); + + } + + public static void main(String[] args) { + //Schedule a job for the event-dispatching thread: + //creating and showing this application's GUI. + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + } + static class CheckAiMove extends TimerTask { + Random rand = new Random(); + int i,j; + boolean [][]aiField= new boolean[3][3]; + public void run() { + if (whosequeue.equals(WhoseQueue.CROSS) && ai && action) { + //int i,j; + nmove++; + if (firstMoveAi) { + do { + i = rand.nextInt(3); + j = rand.nextInt(3); + //System.out.println("Random i:"+i); + //System.out.println("Random j:"+j); + }while(field[i][j]!=FieldGame.FREE); + firstMoveAi=false; + } + else + checkAiField(); + Toolkit.getDefaultToolkit().beep(); + button[i][j].setText("X"); + field[i][j]=FieldGame.CROSS; + // Jesli wygrana komputera + if (win(FieldGame.CROSS)) { + label.setText("Wygral KRZYZ"); + action=false; + //System.out.println("ROBOT Wygrana KRZYZA nmove:"+nmove); + } + // to moze remis + else if (nmove==9){ + label.setText("Remis"); + action=false; + //System.out.println("ROBOT Remis nmove:"+nmove); + } + // w przeciwnym razie ruch kola + else { + whosequeue=WhoseQueue.WHELL; + label.setText("Ruch KOLA"); + //System.out.println("ROBOT Ruch KOLA nmove:"+nmove); + } + } + } + private void checkAiField() { + boolean out=false; + int accumulation=0, priority=0; + boolean find=false; + + + if (!out) { + // sprawdza wolne miejsce w poziomie z lewej na prawa + + for (int a=0;a<3;a++) { + for (int b=0;b<3;b++) { + if (field[a][b]==FieldGame.CROSS && + field[a][b]!=FieldGame.WHELL) accumulation++; + if (field[a][b]==FieldGame.WHELL) accumulation=0; + if (field[a][b]==FieldGame.FREE && + accumulation!=0) {i=a; j=b;out=true;find=true;priority=accumulation;System.out.println("w Poziomych 1");break;} + } + accumulation=0; + if (out) break; + } + } + // sprawdza wolne miejsce w poziomie z prawej na lewa + if (!out) { + //out=false; + //System.out.println("w Poziomych 2"); + for (int a=2;a>=0;a--) { + for (int b=2;b>=0;b--) { + if (field[a][b]==FieldGame.CROSS && + field[a][b]!=FieldGame.WHELL) accumulation++; + if (field[a][b]==FieldGame.WHELL) accumulation=0; + if (field[a][b]==FieldGame.FREE && + accumulation!=0) {i=a; j=b;out=true;find=true;priority=accumulation;System.out.println("w Poziomych 2");break;} + } + accumulation=0; + if (out) break; + } + } + // sprawdza wolne miejsce pionowo z gory na dol + if (!out) { + + //out=false; + for (int a=0;a<3;a++) { + for (int b=0;b<3;b++) { + if (field[b][a]==FieldGame.CROSS && + field[b][a]!=FieldGame.WHELL) accumulation++; + if (field[b][a]==FieldGame.WHELL) accumulation=0; + if (field[b][a]==FieldGame.FREE && + accumulation!=0) {i=b; j=a;out=true;find=true;priority=accumulation;System.out.println("w Pionowych 1");break;} + } + accumulation=0; + if (out) break; + } + } + // sprawdza wolne miejsce pionowo z dolu do gory + if (!out) { + for (int a=2;a>=0;a--) { + for (int b=2;b>=0;b--) { + if (field[b][a]==FieldGame.CROSS && + field[b][a]!=FieldGame.WHELL) accumulation++; + if (field[b][a]==FieldGame.WHELL) accumulation=0; + if (field[b][a]==FieldGame.FREE && + accumulation!=0) {i=b; j=a;out=true;find=true;priority=accumulation;System.out.println("w Pionowych 2");break;} + } + accumulation=0; + if (out) break; + } + } + // szukanie miejsca na ukos + if (priority<2) { + out=false; + if (!out) { + if (field[0][0].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.CROSS) && + field[2][2].equals(FieldGame.FREE)) { + i=2; j=2;out=true;find=true;priority=2;System.out.println("unslash od gory"); + + } + } + if (!out) { + if (field[0][0].equals(FieldGame.CROSS) && + field[2][2].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.FREE)) { + i=1; j=1;out=true;find=true;priority=2;System.out.println("unslash od gory z dziura w srodku"); + + } + } + if (!out){ + if (field[0][2].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.CROSS) && + field[2][0].equals(FieldGame.FREE)) { + i=2; j=0;out=true;find=true;priority=2;System.out.println("slash od gory"); + + } + } + if (!out) { + if (field[2][2].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.CROSS) && + field[0][0].equals(FieldGame.FREE)) { + i=0; j=0;out=true;find=true;priority=2;System.out.println("slash od dolu z dziura w srodku"); + + } + } + if (!out) { + if (field[2][2].equals(FieldGame.CROSS) && + field[0][0].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.FREE)) { + i=1; j=1;out=true;find=true;priority=2;System.out.println("slash od dolu"); + + } + } + if (!out) { + if (field[2][0].equals(FieldGame.CROSS) && + field[1][1].equals(FieldGame.CROSS) && + field[0][2].equals(FieldGame.FREE)) { + i=0; j=2;out=true;find=true;priority=2;System.out.println("slash od dolu"); + + } + } + } + + + + System.out.println("priority: "+priority); + if(priority<2) { + out=false; + if (!out) { + // proboje zablokowac w poziomie z lewej na prawa + for (int a=0;a<3;a++) { + for (int b=0;b<3;b++) { + if (field[a][b]==FieldGame.WHELL) accumulation++; + if (field[a][b]==FieldGame.CROSS) accumulation=0; + if (field[a][b]==FieldGame.FREE && + accumulation==2) {i=a; j=b;out=true;find=true; + System.out.println("Blok w poziomie 1");break;} + } + accumulation=0; + if (out) break; + } + } + if (!out) { + // proboje zablokowac w poziomie z prawej nanlewa + for (int a=2;a>=0;a--) { + for (int b=2;b>=0;b--) { + if (field[a][b]==FieldGame.WHELL) accumulation++; + if (field[a][b]==FieldGame.CROSS) accumulation=0; + if (field[a][b]==FieldGame.FREE && + accumulation==2) {i=a; j=b;out=true;find=true; + System.out.println("Blok w poziomie 2");break;} + } + accumulation=0; + if (out) break; + } + } + if (!out) { + // proboje zablokowac w pionie z lewej na prawa + for (int a=0;a<3;a++) { + for (int b=0;b<3;b++) { + if (field[b][a]==FieldGame.WHELL) accumulation++; + if (field[b][a]==FieldGame.CROSS) accumulation=0; + if (field[b][a]==FieldGame.FREE && + accumulation==2) {i=b; j=a;out=true;find=true; + System.out.println("Blok w pionie 1");break;} + } + accumulation=0; + if (out) break; + } + } + if (!out) { + // proboje zablokowac w pionie z dolu do gory + for (int a=2;a>=0;a--) { + for (int b=2;b>=0;b--) { + if (field[b][a]==FieldGame.WHELL) accumulation++; + if (field[b][a]==FieldGame.CROSS) accumulation=0; + if (field[b][a]==FieldGame.FREE && + accumulation==2) {i=b; j=a;out=true;find=true; + System.out.println("Blok w pionie 2");break;} + } + accumulation=0; + if (out) break; + } + } + } // priority + + + // blokowanie na ukos + if (priority<2) { + out=false; + if (!out) { + if (field[0][0].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.WHELL) && + field[2][2].equals(FieldGame.FREE)) { + i=2; j=2;out=true;find=true;priority=2;System.out.println("blokowanie unslash od gory"); + + } + } + if (!out) { + if (field[0][0].equals(FieldGame.WHELL) && + field[2][2].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.FREE)) { + i=1; j=1;out=true;find=true;priority=2;System.out.println("blokowanie unslash od gory z dziura w srodku"); + + } + } + if (!out){ + if (field[0][2].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.WHELL) && + field[2][0].equals(FieldGame.FREE)) { + i=2; j=0;out=true;find=true;priority=2;System.out.println("blokowanie slash od gory"); + + } + } + if (!out) { + if (field[2][2].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.WHELL) && + field[0][0].equals(FieldGame.FREE)) { + i=0; j=0;out=true;find=true;priority=2;System.out.println("blokowanie slash od dolu z dziura w srodku"); + + } + } + if (!out) { + if (field[2][2].equals(FieldGame.WHELL) && + field[0][0].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.FREE)) { + i=1; j=1;out=true;find=true;priority=2;System.out.println("blokowanie slash od dolu"); + + } + } + if (!out) { + if (field[2][0].equals(FieldGame.WHELL) && + field[1][1].equals(FieldGame.WHELL) && + field[0][2].equals(FieldGame.FREE)) { + i=0; j=2;out=true;find=true;priority=2;System.out.println("blokowanie slash od dolu"); + + } + } + } + + + System.out.println("checkAiField i: "+i+" j: "+j); + // te petle sa na wszelki wypadek + if (!find) { + for (int a=0;a<3;a++) { + for (int b=0;b<3;b++) + if (field[a][b]==FieldGame.FREE) {i=a; j=b;System.out.println("FIND");} + + } + + } + } + } +} diff --git a/wrapper-icon/Jttt.rc b/wrapper-icon/Jttt.rc new file mode 100644 index 0000000..a240999 --- /dev/null +++ b/wrapper-icon/Jttt.rc @@ -0,0 +1 @@ +id ICON "icon/Jttt.ico" diff --git a/wrapper-icon/Makefile.old.win b/wrapper-icon/Makefile.old.win new file mode 100644 index 0000000..107331f --- /dev/null +++ b/wrapper-icon/Makefile.old.win @@ -0,0 +1,33 @@ +CPP = g++.exe +CC = gcc.exe + +WINDRES = windres.exe +RES = +OBJ = wrapper.o $(RES) +LINKOBJ = wrapper.o $(RES) +#LIBS = -L"/lib" -lsdl -lsdl_ttf -mwindows +LIBS = -static-libgcc +INCS = +CXXINCS = +BIN = wrapper.exe +CXXFLAGS = $(CXXINCS) -g +CFLAGS = $(INCS) +RM = rm + +.PHONY: all all-before all-after clean clean-custom + +all: all-before wrapper.exe all-after + + +clean: clean-custom + ${RM} $(OBJ) + ${RM} $(BIN) + + +$(BIN): $(OBJ) + $(CC) $(LINKOBJ) -o "wrapper.exe" $(LIBS) + +wrapper.o: wrapper.c + $(CC) -c wrapper.c -o wrapper.o $(CFLAGS) -DNO_STDIO_REDIRECT + + diff --git a/wrapper-icon/Makefile.win b/wrapper-icon/Makefile.win new file mode 100644 index 0000000..1dfb90f --- /dev/null +++ b/wrapper-icon/Makefile.win @@ -0,0 +1,36 @@ +CPP = g++.exe +CC = i686-w64-mingw32-g++ + +WINDRES = i686-w64-mingw32-windres +RES = +OBJ = wrapper.o $(RES) +LINKOBJ = wrapper.o $(RES) +#LIBS = -L"/lib" -lsdl -lsdl_ttf -mwindows +LIBS = -static-libgcc +INCS = +CXXINCS = +BIN = wrapper.exe +CXXFLAGS = $(CXXINCS) -g +CFLAGS = $(INCS) +RM = rm + +.PHONY: all all-before all-after clean clean-custom + +all: all-before wrapper.exe all-after + + +clean: clean-custom + ${RM} $(OBJ) + ${RM} $(BIN) + + $(WINDRES) Jttt.rc Jttt.res + + +$(BIN): $(OBJ) + $(WINDRES) Jttt.rc -O coff -o icon.o + $(CC) $(LINKOBJ) -o "wrapper.exe" $(LIBS) icon.o + +wrapper.o: wrapper.c + $(CC) -c wrapper.c -o wrapper.o $(CFLAGS) -DNO_STDIO_REDIRECT + + diff --git a/wrapper-icon/config.txt b/wrapper-icon/config.txt new file mode 100644 index 0000000..3628a0e --- /dev/null +++ b/wrapper-icon/config.txt @@ -0,0 +1 @@ +.\jre\bin\javaw.exe -jar Jttt.jar diff --git a/wrapper-icon/icon/Jttt.ico b/wrapper-icon/icon/Jttt.ico new file mode 100644 index 0000000..c5e9ee6 Binary files /dev/null and b/wrapper-icon/icon/Jttt.ico differ diff --git a/wrapper-icon/icon/Trefle.ico b/wrapper-icon/icon/Trefle.ico new file mode 100644 index 0000000..c753797 Binary files /dev/null and b/wrapper-icon/icon/Trefle.ico differ diff --git a/wrapper-icon/icon/ufo-small.ico b/wrapper-icon/icon/ufo-small.ico new file mode 100644 index 0000000..44ed689 Binary files /dev/null and b/wrapper-icon/icon/ufo-small.ico differ diff --git a/wrapper-icon/wrapper.c b/wrapper-icon/wrapper.c new file mode 100644 index 0000000..5ea19f8 --- /dev/null +++ b/wrapper-icon/wrapper.c @@ -0,0 +1,71 @@ +#include // printf +#include // exit +#include +#include // sleep access + +/* +char * current(char * name){ + char *file; + + if (!getenv("CD")) { + printf ("Zmienna srodowiskowa \"CD\" nie istnieje !\n"); + exit (1); + } + file=malloc(strlen(getenv("CD")+strlen(name)+1)); + strcpy(file, getenv("CD")); + strcat(file, name); + + return file; +} +*/ + +char * file_exist(){ + char * name = (char *)".\\config.txt"; + //char *file = current(name); + char *file = name; + + if (access(file, F_OK)==0){ + printf("PLIK istnieje %s\n",file); + free(file); + return file; + } + printf("PLIK nie istnieje %s\n",file); + free(file); + return NULL; +} + + + +void load(){ + + char * file = file_exist(); + char bufor1[128]; + char bufor2[128]; + char bufor3[128]; + char run[384]; + + if (!file) exit(1); + + FILE * f = fopen(file, "r"); + fscanf(f, "%s %s %s", bufor1,bufor2,bufor3); + fclose(f); + strcpy(run, bufor1); + strcat(run, " "); + strcat(run, bufor2); + strcat(run, " "); + strcat(run, bufor3); + printf("Uruchamiam %s \n",run); + free(file); + + system(run); + + + + +} + +int main (){ + load(); + + return 0; +} -- cgit v1.2.3