package com.beyondtechnicallycorrect.pong;


import javax.swing.JFrame;

import com.beyondtechnicallycorrect.pong.ai.AIModule;
import com.beyondtechnicallycorrect.pong.ai.AIRunner;
import com.beyondtechnicallycorrect.pong.ai.AIRunnerFactory;
import com.beyondtechnicallycorrect.pong.models.ball.BallModule;
import com.beyondtechnicallycorrect.pong.models.collision.CollisionModule;
import com.beyondtechnicallycorrect.pong.models.frame.FrameModule;
import com.beyondtechnicallycorrect.pong.models.game.CourtViewModelSubscription;
import com.beyondtechnicallycorrect.pong.models.game.GameModule;
import com.beyondtechnicallycorrect.pong.models.game.MatchStateSubscription;
import com.beyondtechnicallycorrect.pong.models.movement.MovementModule;
import com.beyondtechnicallycorrect.pong.models.paddle.PaddleModule;
import com.beyondtechnicallycorrect.pong.models.placeable.PlaceableModule;
import com.beyondtechnicallycorrect.pong.models.player.PlayerModule;
import com.beyondtechnicallycorrect.pong.models.position.PositionModule;
import com.beyondtechnicallycorrect.pong.models.terminalwall.TerminalWallModule;
import com.beyondtechnicallycorrect.pong.models.velocity.VelocityModule;
import com.beyondtechnicallycorrect.pong.models.wall.WallModule;
import com.beyondtechnicallycorrect.pong.view.PongPanel;
import com.beyondtechnicallycorrect.pong.viewmodel.AppViewModel;
import com.beyondtechnicallycorrect.pong.viewmodel.AppViewModelFactory;
import com.beyondtechnicallycorrect.pong.viewmodel.AppViewModelModule;
import com.google.inject.Guice;
import com.google.inject.Injector;

public class App {

	public static void main(String[] args) {
		javax.swing.SwingUtilities.invokeLater(
				new Runnable() {
					public void run() {
						setupGui();
					}
			});
	}
	
	private static void setupGui() {
		Injector injector = getInjector();
		AppViewModelFactory appViewModelFactory =
				injector.getInstance(AppViewModelFactory.class);
		AppViewModel appViewModel = appViewModelFactory.create();
		
		appViewModel.createMatch();
		
		JFrame frame = new JFrame("Pong");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		CourtViewModelSubscription viewModelChangeSubscription =
				injector.getInstance(CourtViewModelSubscription.class);
		MatchStateSubscription matchStateSubscription =
				injector.getInstance(MatchStateSubscription.class);
		
		AIRunnerFactory aiFactory =
				injector.getInstance(AIRunnerFactory.class);
		AIRunner aiRunner = aiFactory.create(appViewModel);
		matchStateSubscription.subscribe(aiRunner);
		
		PongPanel pongPanel =
				new PongPanel(
						appViewModel,
						viewModelChangeSubscription,
						matchStateSubscription
					);
		frame.getContentPane().add(pongPanel);
		
		frame.pack();
		frame.setVisible(true);
	}
	
	private static Injector getInjector() {
		Injector injector = Guice.createInjector(
				new AIModule(),
				new AppViewModelModule(),
				new BallModule(),
				new CollisionModule(),
				new FrameModule(),
				new GameModule(),
				new MovementModule(),
				new PaddleModule(),
				new PlaceableModule(),
				new PlayerModule(),
				new PositionModule(),
				new TerminalWallModule(),
				new VelocityModule(),
				new WallModule()
			);
		return injector;
	}
	
}

@@ -64,16 +64,48 @@
 .JFrame;
+%0Aimport javax.swing.JOptionPane;
 %0A%0Aimport
@@ -2786,16 +2786,351 @@
 (true);%0A
+%09%09%0A%09%09JOptionPane.showMessageDialog(frame,%0A%09%09%09%09%22Welcome to my Pong implementation!%5Cn%5Cn%22 +%0A%09%09%09%09%09%09%22You are the top paddle, use the 'a' key to%5Cnmove left and the 'd' key to move right.%5Cn%22 +%0A%09%09%09%09%09%09%22Click on 'Start Match' when you are ready%5Cnto start the match.%5Cn%5Cn%22 +%0A%09%09%09%09%09%09%22Good luck!%22,%0A%09%09%09%09%22Welcome!%22,%0A%09%09%09%09JOptionPane.PLAIN_MESSAGE%0A%09%09%09);%0A
 %09%7D%0A%09%0A%09pr

Add instructions for which paddle the player is and for controls