<commit_before>package bbth.game;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Canvas;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.RectF;
import bbth.net.bluetooth.Bluetooth;
import bbth.net.bluetooth.State;
import bbth.net.simulation.LockStepProtocol;
import bbth.ui.UILabel;
import bbth.ui.UIScrollView;
import bbth.core.GameActivity;
import bbth.sound.*;

public class InGameScreen extends UIScrollView {

	private static final float BEAT_LINE_X = 25;
	private static final float BEAT_LINE_Y = 135;
	
	private BBTHSimulation sim;
	private UILabel label;
	private Bluetooth bluetooth;
	private Team team;
	private BeatTracker beatTracker;
	private int combo;
	private int score;
	private String comboStr, scoreStr;
	private List<Beat> beatsInRange;
	private Paint paint;

	public InGameScreen(Team playerTeam, Bluetooth bluetooth, LockStepProtocol protocol) {
		super(null);

		this.team = playerTeam;
		
		// Set up the scrolling!
		this.setSize(BBTHGame.WIDTH, BBTHGame.HEIGHT);
		this.setPosition(0, 0);
		this.setScrolls(false);
		
		// Test labels
		label = new UILabel("", null);
		label.setTextSize(10);
		label.setPosition(10, 10);
		label.setSize(BBTHGame.WIDTH - 20, 10);
		label.setTextAlign(Align.CENTER);
		addSubview(label);

		this.bluetooth = bluetooth;
		sim = new BBTHSimulation(playerTeam, protocol);
		sim.setupSubviews(this);
		
		// Setup paint
		paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		paint.setTextSize(10);
		
		// Setup music stuff
		BeatPattern simplePattern = new SimpleBeatPattern(385, 571, 30000);
		MusicPlayer musicPlayer = new MusicPlayer(GameActivity.instance, R.raw.bonusroom);
		beatTracker = new BeatTracker(musicPlayer, simplePattern);
		beatsInRange = new ArrayList<Beat>();
	}

	@Override
	public void onStop() {
		// Disconnect when we lose focus
		bluetooth.disconnect();
	}

	@Override
	public void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		// Draw a background grid thing so we know we're not hallucinating
		canvas.translate(-this.pos_x, -this.pos_y);
		RectF bounds = this._content_bounds;
		for (float f = bounds.top; f <= bounds.bottom; f += 20) {
			canvas.drawLine(bounds.left, f, bounds.right, f, this._scroll_paint);
		}
		for (float f = bounds.left; f <= bounds.right; f += 20) {
			canvas.drawLine(f, bounds.top, f, bounds.bottom, this._track_paint);
		}<commit_msg>music now plays in ingamescreen<commit_after>package bbth.game;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Canvas;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.RectF;
import bbth.net.bluetooth.Bluetooth;
import bbth.net.bluetooth.State;
import bbth.net.simulation.LockStepProtocol;
import bbth.ui.UILabel;
import bbth.ui.UIScrollView;
import bbth.core.GameActivity;
import bbth.sound.*;
import bbth.sound.MusicPlayer.OnCompletionListener;

public class InGameScreen extends UIScrollView {

	private static final float BEAT_LINE_X = 25;
	private static final float BEAT_LINE_Y = 135;
	
	private BBTHSimulation sim;
	private UILabel label;
	private Bluetooth bluetooth;
	private Team team;
	private BeatTracker beatTracker;
	private int combo;
	private int score;
	private String comboStr, scoreStr;
	private BeatPattern beatPattern;
	private MusicPlayer musicPlayer;
	private List<Beat> beatsInRange;
	private Paint paint;

	public InGameScreen(Team playerTeam, Bluetooth bluetooth, LockStepProtocol protocol) {
		super(null);

		this.team = playerTeam;
		
		// Set up the scrolling!
		this.setSize(BBTHGame.WIDTH, BBTHGame.HEIGHT);
		this.setPosition(0, 0);
		this.setScrolls(false);
		
		// Test labels
		label = new UILabel("", null);
		label.setTextSize(10);
		label.setPosition(10, 10);
		label.setSize(BBTHGame.WIDTH - 20, 10);
		label.setTextAlign(Align.CENTER);
		addSubview(label);

		this.bluetooth = bluetooth;
		sim = new BBTHSimulation(playerTeam, protocol);
		sim.setupSubviews(this);
		
		// Setup paint
		paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		paint.setTextSize(10);
		
		// Setup music stuff
		beatPattern = new SimpleBeatPattern(385, 571, 30000);
		musicPlayer = new MusicPlayer(GameActivity.instance, R.raw.bonusroom);
		musicPlayer.setOnCompletionListener(new OnCompletionListener() {
			public void onCompletion(MusicPlayer mp) {
				beatTracker = new BeatTracker(musicPlayer, beatPattern);
				beatsInRange = new ArrayList<Beat>();
				mp.play();
			}
		});
		
		beatTracker = new BeatTracker(musicPlayer, beatPattern);
		beatsInRange = new ArrayList<Beat>();
		
		// Setup score stuff
		score = 0;
		scoreStr = String.valueOf(score);
		combo = 0;
		comboStr = String.valueOf(combo);
		
		// Start playing the music!
		musicPlayer.play();
	}

	@Override
	public void onStop() {
		musicPlayer.stop();
		// Disconnect when we lose focus
		bluetooth.disconnect();
	}

	@Override
	public void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		// Draw a background grid thing so we know we're not hallucinating
		canvas.translate(-this.pos_x, -this.pos_y);
		RectF bounds = this._content_bounds;
		for (float f = bounds.top; f <= bounds.bottom; f += 20) {
			canvas.drawLine(bounds.left, f, bounds.right, f, this._scroll_paint);
		}
		for (float f = bounds.left; f <= bounds.right; f += 20) {
			canvas.drawLine(f, bounds.top, f, bounds.bottom, this._track_paint);
		}
{'fraction_non_alphanumeric': 0.10854418775210854, 'fraction_numerical': 0.012834616795012835, 'mean_word_length': 4.455, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494700', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1743, 'n_words': 447}