Changed: Made OpenArena::Screen more abstract.
Changed: Updated OPENARENA_VERSION to CVS this should be set to a number for release builds. ~g2k
This commit is contained in:
@@ -8,22 +8,27 @@ namespace OpenArena
|
|||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Screen()
|
Screen();
|
||||||
{
|
int GetWidth();
|
||||||
width=640;
|
int GetHeight();
|
||||||
height=480;
|
int GetColorDepth();
|
||||||
bpp=16;
|
bool GetFullscreen();
|
||||||
fullscreen=false;
|
const char* GetName();
|
||||||
name = "";
|
void SetWidth(int);
|
||||||
}
|
void SetHeight(int);
|
||||||
|
void Resize(int, int);
|
||||||
short width;
|
void SetColorDepth(int);
|
||||||
short height;
|
void SetFullscreen(bool);
|
||||||
char bpp;
|
void ToggleFullscreen();
|
||||||
bool fullscreen;
|
void SetName(const char*);
|
||||||
string name;
|
void SetName(string);
|
||||||
|
protected:
|
||||||
|
short _width;
|
||||||
|
short _height;
|
||||||
|
char _colorDepth;
|
||||||
|
bool _fullscreen;
|
||||||
|
// public:
|
||||||
|
string _name;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
#define OPENARENA_VERSION "OpenArena v0.1.2"
|
//#define OPENARENA_VERSION "OpenArena: v0.1.2"
|
||||||
|
#define OPENARENA_VERSION "OpenArena: CVS"
|
||||||
|
|||||||
@@ -177,6 +177,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\Player.cpp">
|
RelativePath=".\src\Player.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\screen.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\strmanip.cpp">
|
RelativePath=".\src\strmanip.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ namespace OpenArena
|
|||||||
POINT mpos;
|
POINT mpos;
|
||||||
POINT middle;
|
POINT middle;
|
||||||
double angleZ;
|
double angleZ;
|
||||||
middle.x = window.width / 2;
|
middle.x = window.GetWidth() / 2;
|
||||||
middle.y = window.height / 2;
|
middle.y = window.GetHeight() / 2;
|
||||||
GetCursorPos(&mpos);
|
GetCursorPos(&mpos);
|
||||||
SetCursorPos(middle.x, middle.y);
|
SetCursorPos(middle.x, middle.y);
|
||||||
if(mpos.x != middle.x || mpos.y != middle.y)
|
if(mpos.x != middle.x || mpos.y != middle.y)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../include/level.h"
|
#include "../include/level.h"
|
||||||
|
#include "../include/version.h"
|
||||||
|
|
||||||
#pragma comment(lib, "bass.lib")
|
#pragma comment(lib, "bass.lib")
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ namespace OpenArena
|
|||||||
numTextures = 0;
|
numTextures = 0;
|
||||||
textures = NULL;
|
textures = NULL;
|
||||||
|
|
||||||
screen.name = "OpenArena";
|
screen.SetName(OPENARENA_VERSION);
|
||||||
|
|
||||||
showFPS = false;
|
showFPS = false;
|
||||||
showConsole = false;
|
showConsole = false;
|
||||||
@@ -345,7 +346,7 @@ namespace OpenArena
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, screen.width, 0, screen.height, -1, 1);
|
glOrtho(0, screen.GetWidth(), 0, screen.GetHeight(), -1, 1);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -353,13 +354,13 @@ namespace OpenArena
|
|||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0,0);
|
glTexCoord2f(0,0);
|
||||||
glVertex2i(0,screen.height/2);
|
glVertex2i(0,screen.GetHeight()/2);
|
||||||
glTexCoord2f(0,1);
|
glTexCoord2f(0,1);
|
||||||
glVertex2i(0,screen.height);
|
glVertex2i(0,screen.GetHeight());
|
||||||
glTexCoord2f(1,1);
|
glTexCoord2f(1,1);
|
||||||
glVertex2i(screen.width,screen.height);
|
glVertex2i(screen.GetWidth(),screen.GetHeight());
|
||||||
glTexCoord2f(1,0);
|
glTexCoord2f(1,0);
|
||||||
glVertex2i(screen.width,screen.height/2);
|
glVertex2i(screen.GetWidth(),screen.GetHeight()/2);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@@ -523,19 +524,19 @@ namespace OpenArena
|
|||||||
}
|
}
|
||||||
else if(command == "screenwidth")
|
else if(command == "screenwidth")
|
||||||
{
|
{
|
||||||
screen.width = Integer(word(cmd, ++i));
|
screen.SetWidth(Integer(word(cmd, ++i)));
|
||||||
}
|
}
|
||||||
else if(command == "screenheight")
|
else if(command == "screenheight")
|
||||||
{
|
{
|
||||||
screen.height = Integer(word(cmd, ++i));
|
screen.SetHeight(Integer(word(cmd, ++i)));
|
||||||
}
|
}
|
||||||
else if(command == "fullscreen")
|
else if(command == "fullscreen")
|
||||||
{
|
{
|
||||||
screen.fullscreen = Truth(word(cmd, ++i));
|
screen.SetFullscreen(Truth(word(cmd, ++i)));
|
||||||
}
|
}
|
||||||
else if(command == "colordepth")
|
else if(command == "colordepth")
|
||||||
{
|
{
|
||||||
screen.bpp = Integer(word(cmd, ++i));
|
screen.SetColorDepth(Integer(word(cmd, ++i)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1002,9 +1003,10 @@ namespace OpenArena
|
|||||||
output << "set turnspeed " << turnSpeed << endl;
|
output << "set turnspeed " << turnSpeed << endl;
|
||||||
output << "set mousespeed " << mouseSpeed << endl;
|
output << "set mousespeed " << mouseSpeed << endl;
|
||||||
output << "set mouselook " << mlook << endl;
|
output << "set mouselook " << mlook << endl;
|
||||||
output << "set screenwidth " << screen.width << endl;
|
output << "set screenwidth " << screen.GetWidth() << endl;
|
||||||
output << "set screenheight " << screen.height << endl;
|
output << "set screenheight " << screen.GetHeight() << endl;
|
||||||
output << "set colordepth " << screen.bpp << endl;
|
output << "set colordepth " << screen.GetColorDepth() << endl;
|
||||||
|
output << "set fullscreen " << screen.GetFullscreen() << endl;
|
||||||
output << "set maxfps " << maxFPS << endl;
|
output << "set maxfps " << maxFPS << endl;
|
||||||
|
|
||||||
//Control Scheme
|
//Control Scheme
|
||||||
|
|||||||
79
src/screen.cpp
Normal file
79
src/screen.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#include "../include/screen.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
Screen::Screen()
|
||||||
|
{
|
||||||
|
_width=640;
|
||||||
|
_height=480;
|
||||||
|
_colorDepth=16;
|
||||||
|
_fullscreen=false;
|
||||||
|
_name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int Screen::GetWidth()
|
||||||
|
{
|
||||||
|
return _width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Screen::GetHeight()
|
||||||
|
{
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Screen::GetColorDepth()
|
||||||
|
{
|
||||||
|
return _colorDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Screen::GetFullscreen()
|
||||||
|
{
|
||||||
|
return _fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Screen::GetName()
|
||||||
|
{
|
||||||
|
return _name.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetWidth(int width)
|
||||||
|
{
|
||||||
|
_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetHeight(int height)
|
||||||
|
{
|
||||||
|
_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::Resize(int width, int height)
|
||||||
|
{
|
||||||
|
_width = width;
|
||||||
|
_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetColorDepth(int colorDepth)
|
||||||
|
{
|
||||||
|
_colorDepth = colorDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetFullscreen(bool status)
|
||||||
|
{
|
||||||
|
_fullscreen = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::ToggleFullscreen()
|
||||||
|
{
|
||||||
|
_fullscreen = !_fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetName(const char* name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Screen::SetName(string name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -15,7 +15,7 @@ void OpenArena::Window::SwapBuffers()
|
|||||||
void OpenArena::Window::Close()
|
void OpenArena::Window::Close()
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (fullscreen)
|
if (_fullscreen)
|
||||||
{
|
{
|
||||||
ChangeDisplaySettings(NULL, 0);
|
ChangeDisplaySettings(NULL, 0);
|
||||||
ShowCursor(true/*false*/);
|
ShowCursor(true/*false*/);
|
||||||
@@ -80,9 +80,9 @@ bool OpenArena::Window::Open()
|
|||||||
DWORD dwStyle;
|
DWORD dwStyle;
|
||||||
RECT WindowRect;
|
RECT WindowRect;
|
||||||
WindowRect.left=(long)0;
|
WindowRect.left=(long)0;
|
||||||
WindowRect.right=(long)width;
|
WindowRect.right=(long)_width;
|
||||||
WindowRect.top=(long)0;
|
WindowRect.top=(long)0;
|
||||||
WindowRect.bottom=(long)height;
|
WindowRect.bottom=(long)_height;
|
||||||
|
|
||||||
instance = GetModuleHandle(NULL);
|
instance = GetModuleHandle(NULL);
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||||
@@ -102,21 +102,21 @@ bool OpenArena::Window::Open()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen)
|
if (_fullscreen)
|
||||||
{
|
{
|
||||||
DEVMODE dmScreenSettings;
|
DEVMODE dmScreenSettings;
|
||||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||||
dmScreenSettings.dmPelsWidth = width;
|
dmScreenSettings.dmPelsWidth = _width;
|
||||||
dmScreenSettings.dmPelsHeight = height;
|
dmScreenSettings.dmPelsHeight = _height;
|
||||||
dmScreenSettings.dmBitsPerPel = bpp;
|
dmScreenSettings.dmBitsPerPel = _colorDepth;
|
||||||
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
|
|
||||||
|
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","OpenArena",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","OpenArena",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||||
fullscreen = false;
|
_fullscreen = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ bool OpenArena::Window::Open()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullscreen)
|
if (_fullscreen)
|
||||||
{
|
{
|
||||||
dwExStyle = WS_EX_APPWINDOW;
|
dwExStyle = WS_EX_APPWINDOW;
|
||||||
dwStyle = WS_POPUP;
|
dwStyle = WS_POPUP;
|
||||||
@@ -141,14 +141,14 @@ bool OpenArena::Window::Open()
|
|||||||
|
|
||||||
AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle);
|
AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle);
|
||||||
|
|
||||||
if (!(window = CreateWindowEx(dwExStyle, "OpenArena v0.1.0", name.c_str(), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, instance, NULL)))
|
if (!(window = CreateWindowEx(dwExStyle, "OpenArena v0.1.0", GetName(), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, instance, NULL)))
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, bpp, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
|
static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, _colorDepth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
|
||||||
|
|
||||||
if (!(deviceContext=GetDC(window)))
|
if (!(deviceContext=GetDC(window)))
|
||||||
{
|
{
|
||||||
@@ -188,7 +188,7 @@ bool OpenArena::Window::Open()
|
|||||||
ShowWindow(window,SW_SHOW);
|
ShowWindow(window,SW_SHOW);
|
||||||
SetForegroundWindow(window);
|
SetForegroundWindow(window);
|
||||||
SetFocus(window);
|
SetFocus(window);
|
||||||
OnResize(width, height);
|
OnResize(_width, _height);
|
||||||
|
|
||||||
if (!OnInit())
|
if (!OnInit())
|
||||||
{
|
{
|
||||||
@@ -304,11 +304,11 @@ bool OpenArena::Window::Open()
|
|||||||
|
|
||||||
bool OpenArena::Window::Open(string title, int width, int height, int bits, bool fullscreenflag)
|
bool OpenArena::Window::Open(string title, int width, int height, int bits, bool fullscreenflag)
|
||||||
{
|
{
|
||||||
fullscreen = fullscreenflag;
|
_fullscreen = fullscreenflag;
|
||||||
width = width;
|
_width = width;
|
||||||
height = height;
|
_height = height;
|
||||||
bpp = bits;
|
_colorDepth = bits;
|
||||||
name = title;
|
_name = title;
|
||||||
|
|
||||||
return Open();
|
return Open();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
|
|
||||||
InitControls();
|
InitControls();
|
||||||
|
|
||||||
level.glFont.SetScreenDimensions(level.screen.width*2, level.screen.height*2);
|
level.glFont.SetScreenDimensions(level.screen.GetWidth()*2, level.screen.GetHeight()*2);
|
||||||
//level.glFont.BuildFont("oa\\textures\\menu\\font.bmp");//(level.gamedir + "\\textures\\menu\\font.bmp").c_str());
|
//level.glFont.BuildFont("oa\\textures\\menu\\font.bmp");//(level.gamedir + "\\textures\\menu\\font.bmp").c_str());
|
||||||
if (level.nextLevel == "")
|
if (level.nextLevel == "")
|
||||||
{
|
{
|
||||||
@@ -252,7 +252,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
|
|
||||||
g_Screen.SetOnInit(InitGL);
|
g_Screen.SetOnInit(InitGL);
|
||||||
g_Screen.SetOnResize(ReSizeGLScene);
|
g_Screen.SetOnResize(ReSizeGLScene);
|
||||||
if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.width, level.screen.height, level.screen.bpp, level.screen.fullscreen))
|
if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen()))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCursorPos(g_Screen.width/2, g_Screen.height/2);
|
SetCursorPos(g_Screen.GetWidth()/2, g_Screen.GetHeight()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
@@ -583,8 +583,8 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
|||||||
{
|
{
|
||||||
keys[OpenArena::KEY_F1]=false;
|
keys[OpenArena::KEY_F1]=false;
|
||||||
g_Screen.Close();
|
g_Screen.Close();
|
||||||
g_Screen.fullscreen=!g_Screen.fullscreen;
|
g_Screen.ToggleFullscreen();
|
||||||
if (!g_Screen.Open("OpenArena",g_Screen.width,g_Screen.height,g_Screen.bpp,g_Screen.fullscreen))
|
if (!g_Screen.Open("OpenArena",g_Screen.GetWidth(),g_Screen.GetHeight(),g_Screen.GetColorDepth(),g_Screen.GetFullscreen()))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user