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
|
||||
{
|
||||
public:
|
||||
Screen()
|
||||
{
|
||||
width=640;
|
||||
height=480;
|
||||
bpp=16;
|
||||
fullscreen=false;
|
||||
name = "";
|
||||
}
|
||||
|
||||
short width;
|
||||
short height;
|
||||
char bpp;
|
||||
bool fullscreen;
|
||||
string name;
|
||||
|
||||
|
||||
Screen();
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
int GetColorDepth();
|
||||
bool GetFullscreen();
|
||||
const char* GetName();
|
||||
void SetWidth(int);
|
||||
void SetHeight(int);
|
||||
void Resize(int, int);
|
||||
void SetColorDepth(int);
|
||||
void SetFullscreen(bool);
|
||||
void ToggleFullscreen();
|
||||
void SetName(const char*);
|
||||
void SetName(string);
|
||||
protected:
|
||||
short _width;
|
||||
short _height;
|
||||
char _colorDepth;
|
||||
bool _fullscreen;
|
||||
// public:
|
||||
string _name;
|
||||
};
|
||||
};
|
||||
#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
|
||||
RelativePath=".\src\Player.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\screen.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\strmanip.cpp">
|
||||
</File>
|
||||
|
||||
@@ -112,8 +112,8 @@ namespace OpenArena
|
||||
POINT mpos;
|
||||
POINT middle;
|
||||
double angleZ;
|
||||
middle.x = window.width / 2;
|
||||
middle.y = window.height / 2;
|
||||
middle.x = window.GetWidth() / 2;
|
||||
middle.y = window.GetHeight() / 2;
|
||||
GetCursorPos(&mpos);
|
||||
SetCursorPos(middle.x, middle.y);
|
||||
if(mpos.x != middle.x || mpos.y != middle.y)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../include/level.h"
|
||||
#include "../include/version.h"
|
||||
|
||||
#pragma comment(lib, "bass.lib")
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace OpenArena
|
||||
numTextures = 0;
|
||||
textures = NULL;
|
||||
|
||||
screen.name = "OpenArena";
|
||||
screen.SetName(OPENARENA_VERSION);
|
||||
|
||||
showFPS = false;
|
||||
showConsole = false;
|
||||
@@ -345,7 +346,7 @@ namespace OpenArena
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0, screen.width, 0, screen.height, -1, 1);
|
||||
glOrtho(0, screen.GetWidth(), 0, screen.GetHeight(), -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
@@ -353,13 +354,13 @@ namespace OpenArena
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0,0);
|
||||
glVertex2i(0,screen.height/2);
|
||||
glVertex2i(0,screen.GetHeight()/2);
|
||||
glTexCoord2f(0,1);
|
||||
glVertex2i(0,screen.height);
|
||||
glVertex2i(0,screen.GetHeight());
|
||||
glTexCoord2f(1,1);
|
||||
glVertex2i(screen.width,screen.height);
|
||||
glVertex2i(screen.GetWidth(),screen.GetHeight());
|
||||
glTexCoord2f(1,0);
|
||||
glVertex2i(screen.width,screen.height/2);
|
||||
glVertex2i(screen.GetWidth(),screen.GetHeight()/2);
|
||||
glEnd();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
@@ -523,19 +524,19 @@ namespace OpenArena
|
||||
}
|
||||
else if(command == "screenwidth")
|
||||
{
|
||||
screen.width = Integer(word(cmd, ++i));
|
||||
screen.SetWidth(Integer(word(cmd, ++i)));
|
||||
}
|
||||
else if(command == "screenheight")
|
||||
{
|
||||
screen.height = Integer(word(cmd, ++i));
|
||||
screen.SetHeight(Integer(word(cmd, ++i)));
|
||||
}
|
||||
else if(command == "fullscreen")
|
||||
{
|
||||
screen.fullscreen = Truth(word(cmd, ++i));
|
||||
screen.SetFullscreen(Truth(word(cmd, ++i)));
|
||||
}
|
||||
else if(command == "colordepth")
|
||||
{
|
||||
screen.bpp = Integer(word(cmd, ++i));
|
||||
screen.SetColorDepth(Integer(word(cmd, ++i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1002,9 +1003,10 @@ namespace OpenArena
|
||||
output << "set turnspeed " << turnSpeed << endl;
|
||||
output << "set mousespeed " << mouseSpeed << endl;
|
||||
output << "set mouselook " << mlook << endl;
|
||||
output << "set screenwidth " << screen.width << endl;
|
||||
output << "set screenheight " << screen.height << endl;
|
||||
output << "set colordepth " << screen.bpp << endl;
|
||||
output << "set screenwidth " << screen.GetWidth() << endl;
|
||||
output << "set screenheight " << screen.GetHeight() << endl;
|
||||
output << "set colordepth " << screen.GetColorDepth() << endl;
|
||||
output << "set fullscreen " << screen.GetFullscreen() << endl;
|
||||
output << "set maxfps " << maxFPS << endl;
|
||||
|
||||
//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()
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (fullscreen)
|
||||
if (_fullscreen)
|
||||
{
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
ShowCursor(true/*false*/);
|
||||
@@ -80,9 +80,9 @@ bool OpenArena::Window::Open()
|
||||
DWORD dwStyle;
|
||||
RECT WindowRect;
|
||||
WindowRect.left=(long)0;
|
||||
WindowRect.right=(long)width;
|
||||
WindowRect.right=(long)_width;
|
||||
WindowRect.top=(long)0;
|
||||
WindowRect.bottom=(long)height;
|
||||
WindowRect.bottom=(long)_height;
|
||||
|
||||
instance = GetModuleHandle(NULL);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
@@ -102,21 +102,21 @@ bool OpenArena::Window::Open()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
if (_fullscreen)
|
||||
{
|
||||
DEVMODE dmScreenSettings;
|
||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||
dmScreenSettings.dmPelsWidth = width;
|
||||
dmScreenSettings.dmPelsHeight = height;
|
||||
dmScreenSettings.dmBitsPerPel = bpp;
|
||||
dmScreenSettings.dmPelsWidth = _width;
|
||||
dmScreenSettings.dmPelsHeight = _height;
|
||||
dmScreenSettings.dmBitsPerPel = _colorDepth;
|
||||
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
|
||||
|
||||
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)
|
||||
fullscreen = false;
|
||||
_fullscreen = false;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -126,7 +126,7 @@ bool OpenArena::Window::Open()
|
||||
}
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
if (_fullscreen)
|
||||
{
|
||||
dwExStyle = WS_EX_APPWINDOW;
|
||||
dwStyle = WS_POPUP;
|
||||
@@ -141,14 +141,14 @@ bool OpenArena::Window::Open()
|
||||
|
||||
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();
|
||||
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
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)))
|
||||
{
|
||||
@@ -188,7 +188,7 @@ bool OpenArena::Window::Open()
|
||||
ShowWindow(window,SW_SHOW);
|
||||
SetForegroundWindow(window);
|
||||
SetFocus(window);
|
||||
OnResize(width, height);
|
||||
OnResize(_width, _height);
|
||||
|
||||
if (!OnInit())
|
||||
{
|
||||
@@ -304,11 +304,11 @@ bool OpenArena::Window::Open()
|
||||
|
||||
bool OpenArena::Window::Open(string title, int width, int height, int bits, bool fullscreenflag)
|
||||
{
|
||||
fullscreen = fullscreenflag;
|
||||
width = width;
|
||||
height = height;
|
||||
bpp = bits;
|
||||
name = title;
|
||||
_fullscreen = fullscreenflag;
|
||||
_width = width;
|
||||
_height = height;
|
||||
_colorDepth = bits;
|
||||
_name = title;
|
||||
|
||||
return Open();
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
|
||||
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());
|
||||
if (level.nextLevel == "")
|
||||
{
|
||||
@@ -252,7 +252,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
|
||||
g_Screen.SetOnInit(InitGL);
|
||||
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;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
|
||||
}
|
||||
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;
|
||||
g_Screen.Close();
|
||||
g_Screen.fullscreen=!g_Screen.fullscreen;
|
||||
if (!g_Screen.Open("OpenArena",g_Screen.width,g_Screen.height,g_Screen.bpp,g_Screen.fullscreen))
|
||||
g_Screen.ToggleFullscreen();
|
||||
if (!g_Screen.Open("OpenArena",g_Screen.GetWidth(),g_Screen.GetHeight(),g_Screen.GetColorDepth(),g_Screen.GetFullscreen()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user