<commit_before>package flixel.system.scaleModes;

import flixel.FlxCamera;
import flixel.FlxG;
import flixel.math.FlxPoint;

@:allow(flixel.FlxGame)
class BaseScaleMode
{
	public static var gWidth:Int;
	public static var gHeight:Int;
	
	public var deviceSize(default, null):FlxPoint;
	public var gameSize(default, null):FlxPoint;
	public var scale(default, null):FlxPoint;
	public var offset(default, null):FlxPoint;
	
	private static var zoom:FlxPoint = FlxPoint.get();
	
	public function new()
	{
		deviceSize = FlxPoint.get();
		gameSize = FlxPoint.get();
		scale = FlxPoint.get();
		offset = FlxPoint.get();
	}
	
	public function onMeasure(Width:Int, Height:Int):Void
	{
		FlxG.width = BaseScaleMode.gWidth;
		FlxG.height = BaseScaleMode.gHeight;
		
		updateGameSize(Width, Height);
		updateDeviceSize(Width, Height);
		updateScaleOffset();
		updateGamePosition();
	}
	
	private function updateGameSize(Width:Int, Height:Int):Void
	{
		gameSize.set(Width, Height);
	}
	
	private function updateDeviceSize(Width:Int, Height:Int):Void
	{
		deviceSize.set(Width, Height);
	}
	
	private function updateScaleOffset():Void
	{
		scale.x = gameSize.x / (FlxG.width * FlxG.initialZoom);
		scale.y = gameSize.y / (FlxG.height * FlxG.initialZoom);
		offset.x = Math.ceil((deviceSize.x - gameSize.x) * 0.5);
		offset.y = Math.ceil((deviceSize.y - gameSize.y) * 0.5);
	}
	
	private function updateGamePosition():Void
	{
		FlxG.game.x = offset.x;
		FlxG.game.y = offset.y;
	}
}<commit_msg>scale mode alignment - haven't tested it yet<commit_after>package flixel.system.scaleModes;

import flixel.FlxCamera;
import flixel.FlxG;
import flixel.math.FlxPoint;

@:allow(flixel.FlxGame)
class BaseScaleMode
{
	public static var gWidth:Int;
	public static var gHeight:Int;
	
	public var deviceSize(default, null):FlxPoint;
	public var gameSize(default, null):FlxPoint;
	public var scale(default, null):FlxPoint;
	public var offset(default, null):FlxPoint;
	
	public var hAlign(default, set):HAlign = HAlign.Center;
	public var vAlign(default, set):VAlign = VAlign.Center;
	
	private static var zoom:FlxPoint = FlxPoint.get();
	
	public function new()
	{
		deviceSize = FlxPoint.get();
		gameSize = FlxPoint.get();
		scale = FlxPoint.get();
		offset = FlxPoint.get();
	}
	
	public function onMeasure(Width:Int, Height:Int):Void
	{
		FlxG.width = BaseScaleMode.gWidth;
		FlxG.height = BaseScaleMode.gHeight;
		
		updateGameSize(Width, Height);
		updateDeviceSize(Width, Height);
		updateScaleOffset();
		updateGamePosition();
	}
	
	private function updateGameSize(Width:Int, Height:Int):Void
	{
		gameSize.set(Width, Height);
	}
	
	private function updateDeviceSize(Width:Int, Height:Int):Void
	{
		deviceSize.set(Width, Height);
	}
	
	private function updateScaleOffset():Void
	{
		scale.x = gameSize.x / (FlxG.width * FlxG.initialZoom);
		scale.y = gameSize.y / (FlxG.height * FlxG.initialZoom);
		updateOffsetX();
		updateOffsetY();
	}
	
	private function updateOffsetX():Void
	{
		switch (hAlign)
		{
			case HAlign.Left:
				offset.x = 0;
			case HAlign.Center:
				offset.x = Math.ceil((deviceSize.x - gameSize.x) * 0.5);
			case HAlign.Right:
				offset.x = deviceSize.x - gameSize.x;
		}
	}
	
	private function updateOffsetY():Void
	{
		switch (vAlign)
		{
			case VAlign.Top:
				offset.y = 0;
			case VAlign.Center:
				offset.y = Math.ceil((deviceSize.y - gameSize.y) * 0.5);
			case VAlign.Bottom:
				offset.y = deviceSize.y - gameSize.y;
		}
	}
	
	private function updateGamePosition():Void
	{
		FlxG.game.x = offset.x;
		FlxG.game.y = offset.y;
	}
	
	private function set_hAlign(value:HAlign):HAlign
	{
		hAlign = value;
		updateOffsetX();
		updateGamePosition();
	}
	
	private function set_vAlign(value:VAlign):VAlign
	{
		vAlign = value;
		updateOffsetY();
		updateGamePosition();
	}
}

enum HAlign 
{
	Left;
	Center;
	Right;
}

enum VAlign
{
	Top;
	Center;
	Bottom;
}
{'fraction_non_alphanumeric': 0.12933264355923435, 'fraction_numerical': 0.002586652871184687, 'mean_word_length': 4.156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4879898', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1404, 'n_words': 280}