1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
| import java.awt.*;
import javax.swing.* ;
import java.io.*;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.plaf.TabbedPaneUI;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
public class Projet
{
public static void main (String args[]) throws IOException
{
FenText fen = new FenText() ;
fen.setBounds (650,300,400,350) ;
fen.setVisible(true) ;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
fen.setLocation((screen.width - fen.getSize().width)/2,(screen.height - fen.getSize().height)/2);
JOptionPane.showMessageDialog(null, "Bienvenue dans LaunchGames v1.2 crée par la Team SkyZen.") ;
}
}
class FenText extends JFrame
{
private static final long serialVersionUID = 1L;
public FenText ()
{
setTitle ("LaunchGames v1.2 By Team SkyZen") ;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize (400, 350) ;
ButtonGroup groupe = new ButtonGroup() ;
Container contenu = getContentPane() ;
getContentPane().setLayout(null) ;
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) ;
}
catch (Exception exc)
{
JOptionPane.showMessageDialog(null, "Impossible de charger le theme du logiciel.", "Theme introuvable.",
JOptionPane.ERROR_MESSAGE) ;
}
Process myProcessa = null;
InputStream myOuta = null;
try
{
myProcessa = Runtime.getRuntime().exec("reg query HKEY_CLASSES_ROOT\\steam\\Shell\\Open\\Command /ve");
myOuta = myProcessa.getInputStream();
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null, "LaunchGames n'a pas trouvé Steam.exe dans votre ordinateur.", "Steam introuvable",
JOptionPane.ERROR_MESSAGE) ;
}
String s7 = "";
int b7 = -1;
do
{
try
{
if(b7 != -1)
s7 += (char)b7;
b7 = myOuta.read();
}
catch(IOException e)
{
JOptionPane.showMessageDialog(null, "Impossible de trouver le script.", "Script introuvable",
JOptionPane.ERROR_MESSAGE) ;
}
} while(b7 != -1);
String[] splitted5 = s7.split("\"");
String path789 = splitted5[1] ;
path789 = path789.substring(0, path789.lastIndexOf('\\'));
String ligneLogin = "\"AutoLoginUser\"";
String ligne = "";
String fichier = path789+"\\config\\SteamAppData.vdf";
String userName = "";
BufferedReader ficTexte;
try
{
ficTexte = new BufferedReader(new FileReader(new File(fichier)));
if (ficTexte == null)
{
JOptionPane.showMessageDialog(null, "Impossible de lire SteamAppData.", "SteamAppData introuvable",
JOptionPane.ERROR_MESSAGE) ;
}
ligne = ficTexte.readLine();
while(ligne != null)
{
ligne = ligne.trim();
if(ligne.startsWith(ligneLogin))
{
String splitted[] = ligne.split("\"");
userName = splitted[3];
break;
}
ligne = ficTexte.readLine();
}
ficTexte.close();
}
catch (FileNotFoundException e)
{
JOptionPane.showMessageDialog(null, "Impossible de trouver SteamAppData.vdf .", "Erreur dans la recherche",
JOptionPane.ERROR_MESSAGE) ;
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null, "Copie du script impossible.", "Erreur.",
JOptionPane.ERROR_MESSAGE) ;
}
File MyFile = new File(path789+"\\steamapps\\"+userName+"\\counter-strike source\\cstrike\\cfg\\configuser.cfg");
MyFile.delete();
barreMenus = new JMenuBar() ;
setJMenuBar(barreMenus) ;
help = new JMenu ("?") ;
barreMenus.add(help) ;
aide = new JMenuItem ("Aide") ;
help.add(aide) ;
site = new JMenuItem ("Blog") ;
help.add(site) ;
apropos = new JMenuItem ("A propos") ;
help.add(apropos) ;
maj = new JMenuItem ("Mise à jour") ;
help.add(maj) ;
exit = new JMenuItem ("Quitter") ;
help.add(exit) ;
oui = new JRadioButton ("Oui") ;
groupe.add(oui) ;
contenu.add(oui) ;
oui.setBounds(100, 110, 50, 15) ;
Aucun = new JRadioButton ("Aucun") ;
groupe.add(Aucun) ;
contenu.add(Aucun) ;
Aucun.setBounds(150, 111, 70, 15) ;
ip = new JTextField ("Adresse IP", 20) ;
ip.setEditable(true) ;
contenu.add(ip) ;
ip.setBounds(95, 70, 230, 20) ;
mdp = new JTextField ("Mot de passe", 10) ;
mdp.setEditable(true);
contenu.add(mdp) ;
mdp.setBounds(225, 110, 100, 20) ;
co = new JButton ("Connexion") ;
contenu.add(co) ;
co.setBounds(147, 155, 95, 40) ;
option = new JButton ("Options avancées ...") ;
contenu.add(option) ;
option.setBounds(130, 215, 130, 30) ;
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon = createImageIcon("images/middle.gif");
JComponent panel1 = makeTextPanel("Test 1");
tabbedPane.addTab("Connexion", icon, panel1,
"Does nothing");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
JComponent panel2 = makeTextPanel(" Test 2 ");
tabbedPane.addTab("Options avancées", icon, panel2,
"Does twice as much nothing");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
// Donc on ajoute les onglets à la JMenuBar, mais j'aimerai les ajouter à la fenêtre, ceci fait, je pense me débrouiller.
// this.add(tabbedPane);
// fen.add(tabbedPane);
// this.add(tabbedPane);
// et add(tabbedPane);
// Ne marchent pas et / ou n'affiche rien.
barreMenus.add(tabbedPane);
}
public static void writeFile(String file, String toWrite) throws IOException
{
FileWriter fw = new FileWriter(file, true);
fw.write(toWrite + "\n\r");
fw.close();
}
protected JComponent makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
protected static ImageIcon createImageIcon(String pat1h) {
java.net.URL imgURL = TabbedPaneUI.class.getResource(pat1h);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + pat1h);
return null;
}
}
private JRadioButton Aucun, oui ;
private JMenuItem apropos, maj, exit, aide, site;
private JMenuBar barreMenus ;
private JMenu help;
private JTextField ip, mdp ;
private JButton co, option;
} |
Partager