aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ScreenSizeCalculator.cpp
blob: 32e942a791e6b98169589f448af54e805d4bff49 (plain)
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
#include "stdafx.h"
#include "ScreenSizeCalculator.h"
#include "Options.h"

ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int height, int forceScale/*=-1*/)
{
    w = width;
    h = height;
	if( forceScale == -1 )
	{
		scale = 1;

		int maxScale = options->guiScale;
		if (maxScale == 0) maxScale = 1000;
		while (scale < maxScale && w / (scale + 1) >= 320 && h / (scale + 1) >= 240)
		{
			scale++;
		}
	}
	else
	{
		scale = forceScale;
	}
    rawWidth = w / (double) scale;
    rawHeight = h / (double) scale;
    w = (int) ceil(rawWidth);
    h = (int) ceil(rawHeight);
}

int ScreenSizeCalculator::getWidth()
{
	return w;
}

int ScreenSizeCalculator::getHeight()
{
	return h;
}