we no longer need the Viewport size

This commit is contained in:
Tim Felgentreff 2020-04-15 14:44:36 +02:00
parent e884ceece2
commit c7b725bb11
9 changed files with 13 additions and 34 deletions

View file

@ -214,7 +214,7 @@ struct EventCallback {
class CVideo
{
public:
CVideo() : Width(0), Height(0), ViewportWidth(0), ViewportHeight(0), Depth(0), ShaderIndex(0), FullScreen(false) {}
CVideo() : Width(0), Height(0), Depth(0), ShaderIndex(0), FullScreen(false) {}
void LockScreen();
void UnlockScreen();
@ -287,8 +287,6 @@ public:
int Width;
int Height;
int ViewportWidth; /// Actual width of the window
int ViewportHeight; /// Actual height of the window
SDL_Cursor *blankCursor;
int Depth;
int ShaderIndex;

View file

@ -170,7 +170,7 @@ void UpdateDisplay()
{
if (GameRunning || Editor.Running == EditorEditing) {
// to prevent empty spaces in the UI
Video.FillRectangleClip(ColorBlack, 0, 0, Video.ViewportWidth, Video.ViewportHeight);
Video.FillRectangleClip(ColorBlack, 0, 0, Video.Width, Video.Height);
DrawMapArea();
DrawMessages();

View file

@ -567,16 +567,14 @@ void ParseCommandLine(int argc, char **argv, Parameters &parameters)
Usage();
exit(-1);
}
Video.ViewportHeight = atoi(sep + 1);
Video.Height = atoi(sep + 1);
*sep = 0;
Video.ViewportWidth = atoi(optarg);
if (!Video.ViewportHeight || !Video.ViewportWidth) {
Video.Width = atoi(optarg);
if (!Video.Height || !Video.Width) {
fprintf(stderr, "%s: incorrect format of video mode resolution -- '%sx%s'\n", argv[0], optarg, sep + 1);
Usage();
exit(-1);
}
Video.Height = Video.ViewportHeight;
Video.Width = Video.ViewportWidth;
continue;
}
case 'W':

View file

@ -11,8 +11,6 @@ class CVideo
public:
int Width;
int Height;
int ViewportWidth;
int ViewportHeight;
int Depth;
int ShaderIndex;
bool FullScreen;

View file

@ -305,8 +305,8 @@ void UiToggleBigMap()
UI.MapArea.X = 0;
UI.MapArea.Y = 0;
UI.MapArea.EndX = Video.ViewportWidth - 1;
UI.MapArea.EndY = Video.ViewportHeight - 1;
UI.MapArea.EndX = Video.Width - 1;
UI.MapArea.EndY = Video.Height - 1;
SetViewportMode(UI.ViewportMode);

View file

@ -212,11 +212,9 @@ static int CclSetVideoResolution(lua_State *l)
LuaCheckArgs(l, 2);
if (CclInConfigFile) {
// May have been set from the command line
if (!Video.ViewportWidth || !Video.ViewportHeight) {
Video.ViewportWidth = LuaToNumber(l, 1);
Video.ViewportHeight = LuaToNumber(l, 2);
Video.Height = Video.ViewportHeight;
Video.Width = Video.ViewportWidth;
if (!Video.Width || !Video.Height) {
Video.Width = LuaToNumber(l, 1);
Video.Height = LuaToNumber(l, 2);
}
}
return 0;

View file

@ -321,8 +321,8 @@ void SaveScreenshotPNG(const char *name)
png_init_io(png_ptr, fp);
int pngw, pngh;
pngw = Video.ViewportWidth;
pngh = Video.ViewportHeight;
pngw = Video.Width;
pngh = Video.Height;
png_set_IHDR(png_ptr, info_ptr, pngw, pngh, 8,
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);

View file

@ -315,8 +315,6 @@ void InitVideoSdl()
}
if (!Video.Width || !Video.Height) {
Video.ViewportWidth = Video.Width;
Video.ViewportHeight = Video.Height;
Video.Width = 640;
Video.Height = 480;
}
@ -333,13 +331,8 @@ void InitVideoSdl()
win_title = Parameters::Instance.applicationName.c_str();
}
if (!Video.ViewportWidth || !Video.ViewportHeight) {
Video.ViewportWidth = Video.Width;
Video.ViewportHeight = Video.Height;
}
TheWindow = SDL_CreateWindow(win_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
Video.ViewportWidth, Video.ViewportHeight, flags);
Video.Width, Video.Height, flags);
if (TheWindow == NULL) {
fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
Video.Width, Video.Height, Video.Depth, SDL_GetError());
@ -514,9 +507,6 @@ static void SdlDoEvent(const EventCallback &callbacks, SDL_Event &event)
&& (event.motion.x != UI.MouseWarpPos.x || event.motion.y != UI.MouseWarpPos.y)) {
int xw = UI.MouseWarpPos.x;
int yw = UI.MouseWarpPos.y;
// Scale mouse-coordinates to viewport
xw = (Uint16)floorf(xw * float(Video.ViewportWidth) / Video.Width);
yw = (Uint16)floorf(yw * float(Video.ViewportHeight) / Video.Height);
UI.MouseWarpPos.x = -1;
UI.MouseWarpPos.y = -1;
SDL_WarpMouseInWindow(TheWindow, xw, yw);
@ -764,7 +754,6 @@ void ToggleFullScreen()
{
Uint32 flags;
flags = SDL_GetWindowFlags(TheWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
SDL_GetWindowSize(TheWindow, &Video.ViewportWidth, &Video.ViewportHeight);
#ifdef USE_WIN32

View file

@ -267,8 +267,6 @@ void CVideo::ClearScreen()
bool CVideo::ResizeScreen(int w, int h)
{
if (VideoValidResolution(w, h)) {
ViewportWidth = w;
ViewportHeight = h;
Width = w;
Height = h;