A bunch of changes to add a platform independent event api.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006 by Tom Hicks *
|
* Copyright (C) 2006 by Tom Hicks *
|
||||||
* tomhicks@cse.buffalo.edu *
|
* tomhicks@cse.buffalo.edu *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@@ -36,21 +36,40 @@ namespace OpenArena
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::SendEvent(Event* event)
|
|
||||||
|
void EventManager::SendEvent(Events::Event* event)
|
||||||
{
|
{
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
||||||
for(index=0; index < eventHandlers.Length(); index++)
|
for(index=0; index < eventHandlers.Length(); index++)
|
||||||
{
|
{
|
||||||
Event::EventHandler* handler = eventHandlers[index];
|
Events::Event::EventHandler* handler = eventHandlers[index];
|
||||||
if(handler->Handles(event->GetEventType()))
|
if(handler->Handles(event->GetEventType()))
|
||||||
{
|
{
|
||||||
handler->HandleEvent(event);
|
handler->HandleEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::RegisterEventHandler(Event::EventHandler* eventHandler)
|
/*
|
||||||
|
void EventManager::SendEvent(Events::Event event)
|
||||||
|
{
|
||||||
|
unsigned int index;
|
||||||
|
|
||||||
|
for(index=0; index < eventHandlers.Length(); index++)
|
||||||
|
{
|
||||||
|
Events::Event::EventHandler* handler = eventHandlers[index];
|
||||||
|
if(handler->Handles(event.GetEventType()))
|
||||||
|
{
|
||||||
|
handler->HandleEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void EventManager::RegisterEventHandler(Events::Event::EventHandler* eventHandler)
|
||||||
{
|
{
|
||||||
eventHandlers.Insert(eventHandler);
|
eventHandlers.Insert(eventHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,6 @@
|
|||||||
|
|
||||||
#include "Events/Event.h"
|
#include "Events/Event.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @file EventManager.h
|
|
||||||
* @breif Specification of the EventManager class
|
|
||||||
* This file along with EventManager.cpp implement the EventManager
|
|
||||||
* class. The EventManager class collects and redistributes events
|
|
||||||
* in a fashion similar to AWT's EventListeners.
|
|
||||||
*
|
|
||||||
* @see EventManager.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
@@ -39,10 +29,10 @@ namespace OpenArena
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventManager();
|
EventManager();
|
||||||
void SendEvent(Event* event);
|
void SendEvent(Events::Event* event);
|
||||||
void RegisterEventHandler(Event::EventHandler* eventHandler);
|
void RegisterEventHandler(Events::Event::EventHandler* eventHandler);
|
||||||
private:
|
private:
|
||||||
list<Event::EventHandler*> eventHandlers;
|
list<Events::Event::EventHandler*> eventHandlers;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif /*__OpenArena_EventMangaer_h__*/
|
#endif /*__OpenArena_EventMangaer_h__*/
|
||||||
|
|||||||
0
src/Events/AxisMotionEvent.cpp
Normal file
0
src/Events/AxisMotionEvent.cpp
Normal file
0
src/Events/AxisMotionEvent.h
Normal file
0
src/Events/AxisMotionEvent.h
Normal file
@@ -1,30 +1,45 @@
|
|||||||
#include "DrawEvent.h"
|
#include "DrawEvent.h"
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
|
|
||||||
OpenArena::DrawEvent::DrawEvent()
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
}
|
namespace Events
|
||||||
|
|
||||||
OpenArena::DrawEvent::~DrawEvent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenArena::Event::EventType OpenArena::DrawEvent::GetEventType()
|
|
||||||
{
|
|
||||||
return Event::DrawEventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenArena::DrawEvent::DrawEventHandler::Handles(OpenArena::Event::EventType type)
|
|
||||||
{
|
|
||||||
if(type == Event::DrawEventType)
|
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
}
|
DrawEvent::DrawEvent()
|
||||||
|
{
|
||||||
return false;
|
SetEventType(Event::DrawEventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenArena::DrawEvent::DrawEventHandler::HandleEvent(OpenArena::Event* event)
|
DrawEvent::~DrawEvent()
|
||||||
{
|
{
|
||||||
DrawGLScene();
|
}
|
||||||
}
|
|
||||||
|
bool DrawEvent::DrawEventHandler::Handles(Event::EventType type)
|
||||||
|
{
|
||||||
|
if(type == Event::DrawEventType)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void DrawEvent::DrawEventHandler::HandleEvent(Event event)
|
||||||
|
{
|
||||||
|
DrawGLScene();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void DrawEvent::DrawEventHandler::HandleEvent(Event* event)
|
||||||
|
{
|
||||||
|
DrawGLScene(_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawEvent::DrawEventHandler::DrawEventHandler(Level* level)
|
||||||
|
{
|
||||||
|
_level = level;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,21 +3,29 @@
|
|||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "../Geometry2D/Rectangle.h"
|
#include "../Geometry2D/Rectangle.h"
|
||||||
|
#include "../level.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
class DrawEvent :public OpenArena::Event
|
namespace Events
|
||||||
{
|
{
|
||||||
public:
|
class DrawEvent :public OpenArena::Events::Event
|
||||||
class DrawEventHandler :public EventHandler
|
|
||||||
{
|
{
|
||||||
virtual bool Handles(EventType type);
|
public:
|
||||||
virtual void HandleEvent(Event* event);
|
class DrawEventHandler :public EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DrawEventHandler(Level* level);
|
||||||
|
virtual bool Handles(EventType type);
|
||||||
|
virtual void HandleEvent(Event* event);
|
||||||
|
//virtual void HandleEvent(Event event);
|
||||||
|
private:
|
||||||
|
Level* _level;
|
||||||
|
};
|
||||||
|
|
||||||
|
DrawEvent();
|
||||||
|
virtual ~DrawEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
DrawEvent();
|
|
||||||
virtual ~DrawEvent();
|
|
||||||
virtual Event::EventType GetEventType();
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
49
src/Events/Event.cpp
Normal file
49
src/Events/Event.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
Event::Event()
|
||||||
|
{
|
||||||
|
SetEventType(UnknownEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
Event::~Event()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenArena::Events::Event::EventType Event::GetEventType()
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Event::SetEventType(OpenArena::Events::Event::EventType type)
|
||||||
|
{
|
||||||
|
_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
Event::EventHandler::EventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Event::EventHandler::~EventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Event::EventHandler::Handles(Event::EventType eventType)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Event::EventHandler::HandleEvent(Event* event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void Event::EventHandler::HandleEvent(Event event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,30 +1,42 @@
|
|||||||
#ifndef __OpenArena_Event_h__
|
#ifndef __OpenArena_Event_h__
|
||||||
#define __OpenArena_Event_h__
|
#define __OpenArena_Event_h__
|
||||||
|
#include "../Object.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
class Event
|
namespace Events
|
||||||
{
|
{
|
||||||
public:
|
class Event :public Object
|
||||||
enum EventType
|
|
||||||
{
|
|
||||||
InputEventType,
|
|
||||||
DrawEventType
|
|
||||||
};
|
|
||||||
|
|
||||||
class EventHandler
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool Handles(Event::EventType eventType) = 0;
|
enum EventType
|
||||||
virtual void HandleEvent(Event* event) = 0;
|
{
|
||||||
// virtual ~EventHandler(){};
|
InputEventType,
|
||||||
|
DrawEventType,
|
||||||
|
KeyPressEventType,
|
||||||
|
KeyReleaseEventType,
|
||||||
|
AxisMotionEventType,
|
||||||
|
UnknownEventType
|
||||||
|
};
|
||||||
|
|
||||||
|
class EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EventHandler();
|
||||||
|
virtual bool Handles(Event::EventType eventType);
|
||||||
|
virtual void HandleEvent(Event* event);
|
||||||
|
//virtual void HandleEvent(Event event);
|
||||||
|
virtual ~EventHandler();
|
||||||
|
};
|
||||||
|
|
||||||
|
Event();
|
||||||
|
virtual ~Event();
|
||||||
|
EventType GetEventType();
|
||||||
|
protected:
|
||||||
|
void SetEventType(EventType type);
|
||||||
|
private:
|
||||||
|
EventType _type;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual EventType GetEventType() = 0;
|
|
||||||
|
|
||||||
//remove this
|
|
||||||
Event(){};
|
|
||||||
virtual ~Event(){};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif //__OpenArena_Event_h__
|
#endif //__OpenArena_Event_h__
|
||||||
|
|||||||
68
src/Events/KeyPressEvent.cpp
Normal file
68
src/Events/KeyPressEvent.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#include "KeyPressEvent.h"
|
||||||
|
#include <cstdio>
|
||||||
|
#include "../main.h"
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
KeyPressEvent::KeyPressEvent(OpenArena::Keys key)
|
||||||
|
{
|
||||||
|
printf("KeyPressEvent created");
|
||||||
|
_key = key;
|
||||||
|
SetEventType(KeyPressEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyPressEvent::~KeyPressEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenArena::Keys KeyPressEvent::GetKey()
|
||||||
|
{
|
||||||
|
return _key;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KeyPressEvent::KeyPressEventHandler::Handles(Event::EventType eventType)
|
||||||
|
{
|
||||||
|
if(eventType == Event::KeyPressEventType)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyPressEvent::KeyPressEventHandler::HandleEvent(Event* event)
|
||||||
|
{
|
||||||
|
if(event != 0x0)
|
||||||
|
{
|
||||||
|
if(event->GetEventType() == Event::KeyPressEventType)
|
||||||
|
{
|
||||||
|
KeyPressEvent* ev = (KeyPressEvent*) event;
|
||||||
|
printf("KeyPressed: %s\n", GetKeyName(ev->GetKey()));
|
||||||
|
keys[ev->GetKey()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void KeyPressEvent::KeyPressEventHandler::HandleEvent(Event event)
|
||||||
|
{
|
||||||
|
if(event.GetEventType() == Event::KeyPressEventType)
|
||||||
|
{
|
||||||
|
KeyPressEvent ev = *((KeyPressEvent*)&event);
|
||||||
|
printf("KeyPressed: %s\n", GetKeyName(ev.GetKey()));
|
||||||
|
keys[ev.GetKey()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
KeyPressEvent::KeyPressEventHandler::KeyPressEventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyPressEvent::KeyPressEventHandler::~KeyPressEventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
33
src/Events/KeyPressEvent.h
Normal file
33
src/Events/KeyPressEvent.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __OpenArena_KeyPressEvent_h__
|
||||||
|
#define __OpenArena_KeyPressEvent_h__
|
||||||
|
#include "Event.h"
|
||||||
|
#include "../keys.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
class KeyPressEvent :public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyPressEvent(OpenArena::Keys key);
|
||||||
|
~KeyPressEvent();
|
||||||
|
virtual OpenArena::Keys KeyPressEvent::GetKey();
|
||||||
|
|
||||||
|
class KeyPressEventHandler :public Event::EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyPressEventHandler();
|
||||||
|
virtual bool Handles(Event::EventType eventType);
|
||||||
|
virtual void HandleEvent(Event* event);
|
||||||
|
//virtual void HandleEvent(Event event);
|
||||||
|
virtual ~KeyPressEventHandler();
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
OpenArena::Keys _key;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __OpenArena_KeyPressEvent_h__
|
||||||
67
src/Events/KeyReleaseEvent.cpp
Normal file
67
src/Events/KeyReleaseEvent.cpp
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#include "KeyReleaseEvent.h"
|
||||||
|
#include <cstdio>
|
||||||
|
#include "../main.h"
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
KeyReleaseEvent::KeyReleaseEvent(OpenArena::Keys key)
|
||||||
|
{
|
||||||
|
_key = key;
|
||||||
|
SetEventType(KeyReleaseEventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyReleaseEvent::~KeyReleaseEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenArena::Keys KeyReleaseEvent::GetKey()
|
||||||
|
{
|
||||||
|
return _key;
|
||||||
|
}
|
||||||
|
bool KeyReleaseEvent::KeyReleaseEventHandler::Handles(Event::EventType type)
|
||||||
|
{
|
||||||
|
if(type == Event::KeyReleaseEventType)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyReleaseEvent::KeyReleaseEventHandler::HandleEvent(Event* event)
|
||||||
|
{
|
||||||
|
if(event != 0x0)
|
||||||
|
{
|
||||||
|
if(event->GetEventType() == Event::KeyReleaseEventType)
|
||||||
|
{
|
||||||
|
KeyReleaseEvent* ev = (KeyReleaseEvent*) event;
|
||||||
|
printf("KeyReleased: %s\n", GetKeyName(ev->GetKey()));
|
||||||
|
keys[ev->GetKey()] = false;
|
||||||
|
keys2[ev->GetKey()] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void KeyReleaseEvent::KeyReleaseEventHandler::HandleEvent(Event event)
|
||||||
|
{
|
||||||
|
if(event.GetEventType() == Event::KeyReleaseEventType)
|
||||||
|
{
|
||||||
|
KeyReleaseEvent ev = *((KeyReleaseEvent*)&event);
|
||||||
|
printf("KeyReleased: %s\n", GetKeyName(ev.GetKey()));
|
||||||
|
keys[ev.GetKey()] = false;
|
||||||
|
keys2[ev.GetKey()] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
KeyReleaseEvent::KeyReleaseEventHandler::KeyReleaseEventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyReleaseEvent::KeyReleaseEventHandler::~KeyReleaseEventHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
33
src/Events/KeyReleaseEvent.h
Normal file
33
src/Events/KeyReleaseEvent.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __OpenArena_KeyReleaseEvent_h__
|
||||||
|
#define __OpenArena_KeyReleaseEvent_h__
|
||||||
|
#include "Event.h"
|
||||||
|
#include "../keys.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
class KeyReleaseEvent :public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyReleaseEvent(OpenArena::Keys key);
|
||||||
|
~KeyReleaseEvent();
|
||||||
|
virtual OpenArena::Keys KeyReleaseEvent::GetKey();
|
||||||
|
|
||||||
|
class KeyReleaseEventHandler :public Event::EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyReleaseEventHandler();
|
||||||
|
virtual bool Handles(Event::EventType eventType);
|
||||||
|
virtual void HandleEvent(Event* event);
|
||||||
|
//virtual void HandleEvent(Event event);
|
||||||
|
virtual ~KeyReleaseEventHandler();
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
OpenArena::Keys _key;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __OpenArena_KeyReleaseEvent_h__
|
||||||
@@ -8,12 +8,13 @@ INCLUDE_DIRS = -I$(X11INCLUDEDIR) -DHAVE_CONFIG_H
|
|||||||
LIBRARY_DIRS = -L$(X11LIBDIR)
|
LIBRARY_DIRS = -L$(X11LIBDIR)
|
||||||
OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o player.o
|
OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o player.o
|
||||||
OBJECTS += strmanip.o tga.o vector.o window.o keys.o main.o x11.o EventManager.o Events/DrawEvent.o
|
OBJECTS += strmanip.o tga.o vector.o window.o keys.o main.o x11.o EventManager.o Events/DrawEvent.o
|
||||||
|
OBJECTS += Events/Event.o Object.o Events/KeyPressEvent.o Events/KeyReleaseEvent.o
|
||||||
LIBS = $(LIBRARY_DIRS) -lGL -lGLU -lXxf86vm -lX11
|
LIBS = $(LIBRARY_DIRS) -lGL -lGLU -lXxf86vm -lX11
|
||||||
LIBRARIES =
|
LIBRARIES =
|
||||||
SO_LIBS =
|
SO_LIBS =
|
||||||
SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so
|
SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so
|
||||||
CPPFLAGS = $(INCLUDE_DIRS)
|
CPPFLAGS = $(INCLUDE_DIRS)
|
||||||
LDFLAGS = $(LIBS) -bind_at_load --disable-framework=/Library/Frameworks/OpenGL
|
LDFLAGS = $(LIBS) -bind_at_load -framework OpenGL -framework AGL -framework Carbon
|
||||||
.Phony: all clean install
|
.Phony: all clean install
|
||||||
|
|
||||||
all: ../OpenArena
|
all: ../OpenArena
|
||||||
@@ -41,7 +42,19 @@ oa_video.so:
|
|||||||
oa_input.so:
|
oa_input.so:
|
||||||
|
|
||||||
#Object Files
|
#Object Files
|
||||||
DrawEvent.o: Events/DrawEvent.cpp Events/DrawEvent.h
|
Events/Event.o: Events/Event.cpp Events/Event.h Object.h
|
||||||
|
$(CPP) -c $(INCLUDE_DIRS) -o Events/Event.o Events/Event.cpp
|
||||||
|
|
||||||
|
Object.o: Object.cpp Object.h
|
||||||
|
$(CPP) -c $(INCLUDE_DIRS) -o Object.o Object.cpp
|
||||||
|
|
||||||
|
Events/KeyPressEvent.o: Events/KeyPressEvent.cpp Events/KeyPressEvent.h Events/Event.h
|
||||||
|
$(CPP) -c $(INCLUDE_DIRS) -o Events/KeyPressEvent.o Events/KeyPressEvent.cpp
|
||||||
|
|
||||||
|
Events/KeyReleaseEvent.o: Events/KeyReleaseEvent.cpp Events/KeyReleaseEvent.h Events/Event.h
|
||||||
|
$(CPP) -c $(INCLUDE_DIRS) -o Events/KeyReleaseEvent.o Events/KeyReleaseEvent.cpp
|
||||||
|
|
||||||
|
Events/DrawEvent.o: Events/DrawEvent.cpp Events/DrawEvent.h Events/Event.h
|
||||||
$(CPP) -c $(INCLUDE_DIRS) -o Events/DrawEvent.o Events/DrawEvent.cpp
|
$(CPP) -c $(INCLUDE_DIRS) -o Events/DrawEvent.o Events/DrawEvent.cpp
|
||||||
|
|
||||||
screen.o: screen.cpp screen.h config.h
|
screen.o: screen.cpp screen.h config.h
|
||||||
@@ -89,7 +102,7 @@ keys.o: keys.cpp keys.h config.h
|
|||||||
main.o: macosx.cpp main.h config.h Events/Event.h Events/DrawEvent.h EventManager.h
|
main.o: macosx.cpp main.h config.h Events/Event.h Events/DrawEvent.h EventManager.h
|
||||||
$(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp
|
$(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp
|
||||||
|
|
||||||
x11.o: x11.cpp x11.h EventManager.h
|
x11.o: x11.cpp x11.h EventManager.h main.h mygl.h
|
||||||
$(CPP) -c $(INCLUDE_DIRS) -o x11.o x11.cpp
|
$(CPP) -c $(INCLUDE_DIRS) -o x11.o x11.cpp
|
||||||
|
|
||||||
EventManager.o: EventManager.cpp EventManager.h Events/Event.h
|
EventManager.o: EventManager.cpp EventManager.h Events/Event.h
|
||||||
|
|||||||
17
src/Object.cpp
Normal file
17
src/Object.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
Object::Object()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Object::~Object()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * Object::GetClassName()
|
||||||
|
{
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
};
|
||||||
15
src/Object.h
Normal file
15
src/Object.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef __OpenArena_Object_h__
|
||||||
|
#define __OpenArena_Object_h__
|
||||||
|
|
||||||
|
namespace OpenArena
|
||||||
|
{
|
||||||
|
class Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Object();
|
||||||
|
virtual ~Object();
|
||||||
|
virtual const char* GetClassName();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //__OpenArena_Object_h__
|
||||||
351
src/ctrls.cpp
351
src/ctrls.cpp
@@ -39,255 +39,186 @@
|
|||||||
//
|
//
|
||||||
// Summary of Properties:
|
// Summary of Properties:
|
||||||
// ControlScheme
|
// ControlScheme
|
||||||
// -list<uint8> forward;
|
|
||||||
// A list of the VKeys associated with forward.
|
|
||||||
// -list<uint8> backward;
|
|
||||||
// A list of the VKeys associated with backward.
|
|
||||||
// -list<uint8> lookLeft;
|
|
||||||
// A list of the VKeys associated with turning left.
|
|
||||||
// -list<uint8> lookRight;
|
|
||||||
// A list of the VKeys associated with turning right.
|
|
||||||
// -list<uint8> lookUp;
|
|
||||||
// A list of the VKeys associated with looking up.
|
|
||||||
// -list<uint8> lookDown;
|
|
||||||
// A list of the VKeys associated with looking down.
|
|
||||||
// -list<uint8> moveLeft;
|
|
||||||
// A list of the VKeys associated with strafing left.
|
|
||||||
// -list<uint8> moveRight;
|
|
||||||
// A list of the VKeys associated with strafing right.
|
|
||||||
// -list<uint8> moveUp;
|
|
||||||
// A list of the VKeys associated with jumping.
|
|
||||||
// -list<uint8> moveDown;
|
|
||||||
// A list of the VKeys associated with crouching.
|
|
||||||
// -list<uint8> firePrimary;
|
|
||||||
// A list of the VKeys associated with activating the primary ability of the active item.
|
|
||||||
// -list<uint8> fireSecondary;
|
|
||||||
// A list of the VKeys associated with activating the secondary ablilty of the active item.
|
|
||||||
// -list<uint8> weaponNext;
|
|
||||||
// A list of the VKeys associated with switching to the next item.
|
|
||||||
// -list<uint8> weaponPrev;
|
|
||||||
// A list of the VKeys associated with switching to the previous item.
|
|
||||||
// -list<uint8> toggleLights;
|
|
||||||
// A list of the VKeys associated with turning lighting on and off.
|
|
||||||
// -list<uint8> toggleFPS;
|
|
||||||
// A list of the VKeys associated with turning the FPS display on and off.
|
|
||||||
// -list<uint8> toggleConsole;
|
|
||||||
// A list of the VKeys associated with toggling the display of the console.
|
|
||||||
// -list<uint8> toggleMouseLook;
|
|
||||||
// A list of the VKeys associated with toggling mouse look.
|
|
||||||
// -list<uint8> quickMouseLook;
|
|
||||||
// A list of the VKeys associated with temporarily switching the mouse look mode.
|
|
||||||
// -list<uint8> rollLeft;
|
|
||||||
// A list of the VKeys associated with rolling left.
|
|
||||||
// -list<uint8> rollRight;
|
|
||||||
// A list of the VKeys associated with rolling right.
|
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "ctrls.h"
|
#include "ctrls.h"
|
||||||
|
#include "strmanip.h"
|
||||||
|
using std::string;
|
||||||
|
using std::ostream;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
void ControlScheme::LoadDefaultControlScheme()
|
void ControlScheme::LoadDefaultControlScheme()
|
||||||
{
|
{
|
||||||
forward.Insert(OpenArena::KEY_LBUTTON);
|
Bind(OpenArena::KEY_LBUTTON, ACTION_FORWARD);
|
||||||
backward.Insert(OpenArena::KEY_RBUTTON);
|
Bind(OpenArena::KEY_RBUTTON, ACTION_BACKWARD);
|
||||||
lookLeft.Insert(OpenArena::KEY_LEFT);
|
Bind(OpenArena::KEY_LEFT, ACTION_LOOKLEFT);
|
||||||
lookRight.Insert(OpenArena::KEY_RIGHT);
|
Bind(OpenArena::KEY_RIGHT, ACTION_LOOKRIGHT);
|
||||||
lookUp.Insert(OpenArena::KEY_UP);
|
Bind(OpenArena::KEY_UP, ACTION_LOOKUP);
|
||||||
lookDown.Insert(OpenArena::KEY_DOWN);
|
Bind(OpenArena::KEY_DOWN, ACTION_LOOKDOWN);
|
||||||
moveLeft.Insert(OpenArena::KEY_S);
|
Bind(OpenArena::KEY_S, ACTION_MOVELEFT);
|
||||||
moveRight.Insert(OpenArena::KEY_D);
|
Bind(OpenArena::KEY_D, ACTION_MOVERIGHT);
|
||||||
moveUp.Insert(OpenArena::KEY_SPACE);
|
Bind(OpenArena::KEY_SPACE, ACTION_MOVEUP);
|
||||||
moveDown.Insert(OpenArena::KEY_A);
|
Bind(OpenArena::KEY_A, ACTION_MOVEDOWN);
|
||||||
firePrimary.Insert(OpenArena::KEY_F);
|
Bind(OpenArena::KEY_F, ACTION_FIREPRIMARY);
|
||||||
fireSecondary.Insert(OpenArena::KEY_G);
|
Bind(OpenArena::KEY_G, ACTION_FIRESECONDARY);
|
||||||
weaponNext.Insert(OpenArena::KEY_T);
|
Bind(OpenArena::KEY_T, ACTION_WEAPONNEXT);
|
||||||
weaponPrev.Insert(OpenArena::KEY_R);
|
Bind(OpenArena::KEY_R, ACTION_WEAPONPREV);
|
||||||
toggleLights.Insert(OpenArena::KEY_L);
|
Bind(OpenArena::KEY_L, ACTION_TOGGLE_LIGHTS);
|
||||||
toggleFPS.Insert(OpenArena::KEY_P);
|
Bind(OpenArena::KEY_P, ACTION_TOGGLE_FPS);
|
||||||
toggleConsole.Insert(OpenArena::KEY_OEM_3);
|
Bind(OpenArena::KEY_OEM_3, ACTION_TOGGLE_CONSOLE);
|
||||||
toggleMouseLook.Insert(OpenArena::KEY_M);
|
Bind(OpenArena::KEY_M, ACTION_TOGGLE_MOUSELOOK);
|
||||||
quickMouseLook.Insert(OpenArena::KEY_Q);
|
Bind(OpenArena::KEY_Q, ACTION_QUICKMOUSELOOK);
|
||||||
rollLeft.Insert(OpenArena::KEY_W);
|
Bind(OpenArena::KEY_W, ACTION_ROLLLEFT);
|
||||||
rollRight.Insert(OpenArena::KEY_E);
|
Bind(OpenArena::KEY_E, ACTION_ROLLRIGHT);
|
||||||
}
|
}
|
||||||
void ControlScheme::ClearControlScheme()
|
void ControlScheme::UnBindAll()
|
||||||
{
|
{
|
||||||
backward.Clear();
|
OpenArena::Keys key;
|
||||||
firePrimary.Clear();
|
for(key=(OpenArena::Keys)0; key<(OpenArena::Keys)256; key = (OpenArena::Keys)(key+1))
|
||||||
fireSecondary.Clear();
|
{
|
||||||
forward.Clear();
|
UnBind(key);
|
||||||
lookDown.Clear();
|
}
|
||||||
lookUp.Clear();
|
|
||||||
lookRight.Clear();
|
|
||||||
lookLeft.Clear();
|
|
||||||
moveDown.Clear();
|
|
||||||
moveUp.Clear();
|
|
||||||
moveLeft.Clear();
|
|
||||||
moveRight.Clear();
|
|
||||||
quickMouseLook.Clear();
|
|
||||||
toggleConsole.Clear();
|
|
||||||
toggleFPS.Clear();
|
|
||||||
toggleLights.Clear();
|
|
||||||
toggleMouseLook.Clear();
|
|
||||||
weaponNext.Clear();
|
|
||||||
weaponPrev.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlScheme::Unbind(uint8 key)
|
void ControlScheme::UnBind(OpenArena::Keys key)
|
||||||
{
|
{
|
||||||
backward.Remove(key);
|
keyActions[key] = ACTION_NONE;
|
||||||
firePrimary.Remove(key);
|
|
||||||
fireSecondary.Remove(key);
|
|
||||||
forward.Remove(key);
|
|
||||||
lookDown.Remove(key);
|
|
||||||
lookUp.Remove(key);
|
|
||||||
lookRight.Remove(key);
|
|
||||||
lookLeft.Remove(key);
|
|
||||||
moveDown.Remove(key);
|
|
||||||
moveUp.Remove(key);
|
|
||||||
moveRight.Remove(key);
|
|
||||||
quickMouseLook.Remove(key);
|
|
||||||
toggleConsole.Remove(key);
|
|
||||||
toggleFPS.Remove(key);
|
|
||||||
toggleLights.Remove(key);
|
|
||||||
toggleMouseLook.Remove(key);
|
|
||||||
weaponNext.Remove(key);
|
|
||||||
weaponPrev.Remove(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlScheme::Bind(uint32 action, uint8 key)
|
void ControlScheme::Bind(OpenArena::Keys key, Action action)
|
||||||
|
{
|
||||||
|
keyActions[key] = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlScheme::WriteToStream(std::ostream& output)
|
||||||
|
{
|
||||||
|
//output << " bind " << action << keyname << endl;
|
||||||
|
OpenArena::Keys key;
|
||||||
|
for(key=(OpenArena::Keys)0; key<(OpenArena::Keys)256; key = (OpenArena::Keys)(key+1))
|
||||||
|
{
|
||||||
|
if(keyActions[key] != ACTION_NONE)
|
||||||
|
{
|
||||||
|
output << " bind " << ActionName(keyActions[key]) << GetKeyName(key) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlScheme::Action ControlScheme::GetAction(const char* actionName)
|
||||||
|
{
|
||||||
|
string str = actionName;
|
||||||
|
str = tolower(str);
|
||||||
|
if(str == "none"){
|
||||||
|
return ACTION_NONE;
|
||||||
|
}else if(str == "forward"){
|
||||||
|
return ACTION_FORWARD;
|
||||||
|
}else if(str == "backward"){
|
||||||
|
return ACTION_BACKWARD;
|
||||||
|
}else if(str == "lookleft"){
|
||||||
|
return ACTION_LOOKLEFT;
|
||||||
|
}else if(str == "lookright"){
|
||||||
|
return ACTION_LOOKRIGHT;
|
||||||
|
}else if(str == "lookup"){
|
||||||
|
return ACTION_LOOKUP;
|
||||||
|
}else if(str == "lookdown"){
|
||||||
|
return ACTION_LOOKDOWN;
|
||||||
|
}else if(str == "moveleft"){
|
||||||
|
return ACTION_MOVELEFT;
|
||||||
|
}else if(str == "moveright"){
|
||||||
|
return ACTION_MOVERIGHT;
|
||||||
|
}else if(str == "moveup"){
|
||||||
|
return ACTION_MOVEUP;
|
||||||
|
}else if(str == "movedown"){
|
||||||
|
return ACTION_MOVEDOWN;
|
||||||
|
}else if(str == "rollleft"){
|
||||||
|
return ACTION_ROLLLEFT;
|
||||||
|
}else if(str == "rollright"){
|
||||||
|
return ACTION_ROLLRIGHT;
|
||||||
|
}else if(str == "fireprimary"){
|
||||||
|
return ACTION_FIREPRIMARY;
|
||||||
|
}else if(str == "firesecondary"){
|
||||||
|
return ACTION_FIRESECONDARY;
|
||||||
|
}else if(str == "weaponnext"){
|
||||||
|
return ACTION_WEAPONNEXT;
|
||||||
|
}else if(str == "weaponprev"){
|
||||||
|
return ACTION_WEAPONPREV;
|
||||||
|
}else if(str == "togglelights"){
|
||||||
|
return ACTION_TOGGLE_LIGHTS;
|
||||||
|
}else if(str == "togglefps"){
|
||||||
|
return ACTION_TOGGLE_FPS;
|
||||||
|
}else if(str == "toggleconsole"){
|
||||||
|
return ACTION_TOGGLE_CONSOLE;
|
||||||
|
}else if(str == "togglemouselook"){
|
||||||
|
return ACTION_TOGGLE_MOUSELOOK;
|
||||||
|
}else if(str == "quickmouselook"){
|
||||||
|
return ACTION_QUICKMOUSELOOK;
|
||||||
|
}else{
|
||||||
|
return ACTION_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string ControlScheme::ActionName(Action action)
|
||||||
{
|
{
|
||||||
switch(action)
|
switch(action)
|
||||||
{
|
{
|
||||||
|
case ACTION_NONE:
|
||||||
|
return "none";
|
||||||
case ACTION_FORWARD:
|
case ACTION_FORWARD:
|
||||||
{
|
return "forward";
|
||||||
Unbind(key);
|
|
||||||
forward.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_BACKWARD:
|
case ACTION_BACKWARD:
|
||||||
{
|
return "backward";
|
||||||
Unbind(key);
|
|
||||||
backward.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_LOOKLEFT:
|
case ACTION_LOOKLEFT:
|
||||||
{
|
return "lookleft";
|
||||||
Unbind(key);
|
|
||||||
lookLeft.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_LOOKRIGHT:
|
case ACTION_LOOKRIGHT:
|
||||||
{
|
return "lookright";
|
||||||
Unbind(key);
|
|
||||||
lookRight.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_LOOKUP:
|
case ACTION_LOOKUP:
|
||||||
{
|
return "lookup";
|
||||||
Unbind(key);
|
|
||||||
lookUp.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_LOOKDOWN:
|
case ACTION_LOOKDOWN:
|
||||||
{
|
return "lookdown";
|
||||||
Unbind(key);
|
|
||||||
lookDown.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_MOVELEFT:
|
case ACTION_MOVELEFT:
|
||||||
{
|
return "moveleft";
|
||||||
Unbind(key);
|
|
||||||
moveLeft.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_MOVERIGHT:
|
case ACTION_MOVERIGHT:
|
||||||
{
|
return "moveright";
|
||||||
Unbind(key);
|
|
||||||
moveRight.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_MOVEUP:
|
case ACTION_MOVEUP:
|
||||||
{
|
return "moveup";
|
||||||
Unbind(key);
|
|
||||||
moveUp.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_MOVEDOWN:
|
case ACTION_MOVEDOWN:
|
||||||
{
|
return "movedown";
|
||||||
Unbind(key);
|
|
||||||
moveDown.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_ROLLLEFT:
|
case ACTION_ROLLLEFT:
|
||||||
{
|
return "rollleft";
|
||||||
Unbind(key);
|
|
||||||
rollLeft.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_ROLLRIGHT:
|
case ACTION_ROLLRIGHT:
|
||||||
{
|
return "rollright";
|
||||||
Unbind(key);
|
|
||||||
rollRight.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_FIREPRIMARY:
|
case ACTION_FIREPRIMARY:
|
||||||
{
|
return "fireprimary";
|
||||||
Unbind(key);
|
|
||||||
firePrimary.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_FIRESECONDARY:
|
case ACTION_FIRESECONDARY:
|
||||||
{
|
return "firesecondary";
|
||||||
Unbind(key);
|
|
||||||
fireSecondary.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_WEAPONNEXT:
|
case ACTION_WEAPONNEXT:
|
||||||
{
|
return "weaponnext";
|
||||||
Unbind(key);
|
|
||||||
weaponNext.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_WEAPONPREV:
|
case ACTION_WEAPONPREV:
|
||||||
{
|
return "weaponprev";
|
||||||
Unbind(key);
|
|
||||||
weaponPrev.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_TOGGLE_LIGHTS:
|
case ACTION_TOGGLE_LIGHTS:
|
||||||
{
|
return "togglelights";
|
||||||
Unbind(key);
|
|
||||||
toggleLights.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_TOGGLE_FPS:
|
case ACTION_TOGGLE_FPS:
|
||||||
{
|
return "togglefps";
|
||||||
Unbind(key);
|
|
||||||
toggleFPS.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_TOGGLE_CONSOLE:
|
case ACTION_TOGGLE_CONSOLE:
|
||||||
{
|
return "toggleconsole";
|
||||||
Unbind(key);
|
|
||||||
toggleConsole.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_TOGGLE_MOUSELOOK:
|
case ACTION_TOGGLE_MOUSELOOK:
|
||||||
{
|
return "togglemouselook";
|
||||||
Unbind(key);
|
|
||||||
toggleMouseLook.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case ACTION_QUICKMOUSELOOK:
|
case ACTION_QUICKMOUSELOOK:
|
||||||
{
|
return "quickmouselook";
|
||||||
Unbind(key);
|
|
||||||
quickMouseLook.Insert(key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return "unknown";
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ControlScheme::IsBound(OpenArena::Keys key, Action action)
|
||||||
|
{
|
||||||
|
if(keyActions[key] == action)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
128
src/ctrls.h
128
src/ctrls.h
@@ -23,105 +23,53 @@
|
|||||||
#if defined HAVE_CONFIG_H
|
#if defined HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "list.h"
|
|
||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* This class represents a user's control scheme.
|
|
||||||
*
|
|
||||||
* This class manages a set of actions and their associated keys.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* This could become a set of keys with associated actions.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
*/
|
|
||||||
class ControlScheme
|
class ControlScheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Action{ACTION_FORWARD, ACTION_BACKWARD, ACTION_LOOKLEFT, ACTION_LOOKRIGHT, ACTION_LOOKUP,
|
enum Action
|
||||||
ACTION_LOOKDOWN, ACTION_MOVELEFT, ACTION_MOVERIGHT, ACTION_MOVEUP, ACTION_MOVEDOWN,
|
{
|
||||||
ACTION_ROLLLEFT, ACTION_ROLLRIGHT, ACTION_FIREPRIMARY, ACTION_FIRESECONDARY,
|
ACTION_NONE = 0,
|
||||||
ACTION_WEAPONNEXT, ACTION_WEAPONPREV, ACTION_TOGGLE_LIGHTS, ACTION_TOGGLE_FPS,
|
ACTION_FORWARD,
|
||||||
ACTION_TOGGLE_CONSOLE, ACTION_TOGGLE_MOUSELOOK, ACTION_QUICKMOUSELOOK};
|
ACTION_BACKWARD,
|
||||||
|
ACTION_LOOKLEFT,
|
||||||
|
ACTION_LOOKRIGHT,
|
||||||
|
ACTION_LOOKUP,
|
||||||
|
ACTION_LOOKDOWN,
|
||||||
|
ACTION_MOVELEFT,
|
||||||
|
ACTION_MOVERIGHT,
|
||||||
|
ACTION_MOVEUP,
|
||||||
|
ACTION_MOVEDOWN,
|
||||||
|
ACTION_ROLLLEFT,
|
||||||
|
ACTION_ROLLRIGHT,
|
||||||
|
ACTION_FIREPRIMARY,
|
||||||
|
ACTION_FIRESECONDARY,
|
||||||
|
ACTION_WEAPONNEXT,
|
||||||
|
ACTION_WEAPONPREV,
|
||||||
|
ACTION_TOGGLE_LIGHTS,
|
||||||
|
ACTION_TOGGLE_FPS,
|
||||||
|
ACTION_TOGGLE_CONSOLE,
|
||||||
|
ACTION_TOGGLE_MOUSELOOK,
|
||||||
|
ACTION_QUICKMOUSELOOK,
|
||||||
|
NUM_ACTIONS
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* This method loads a hard coded default control scheme.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
*/
|
|
||||||
void LoadDefaultControlScheme();
|
void LoadDefaultControlScheme();
|
||||||
|
void UnBindAll();
|
||||||
/*!
|
void UnBind(OpenArena::Keys key);
|
||||||
* \brief
|
void Bind(OpenArena::Keys key, Action action);
|
||||||
* This method clears this control scheme so that no keys are bound to any actions.
|
void WriteToStream(std::ostream& output);
|
||||||
*
|
static Action GetAction(const char* actionName);
|
||||||
* \remarks
|
static const char* GetActionName(Action action);
|
||||||
*
|
bool IsBound(OpenArena::Keys key, Action action);
|
||||||
* \see
|
private:
|
||||||
*/
|
std::string ActionName(Action action);
|
||||||
void ClearControlScheme();
|
Action keyActions[256];
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* This method removes a key from all actions.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* The KEY_* constant for the key to unbind.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
*/
|
|
||||||
void Unbind(uint8);
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* This method binds a key to an action.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* The ACTION_* constant for the action to bind to.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* The KEY_* constant for the key to bind.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Returns false if an invalid action is specified and true otherwise.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* This unbinds the key before binding it to the new action.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
*/
|
|
||||||
bool Bind(uint32, uint8);
|
|
||||||
|
|
||||||
list<uint8> forward;
|
|
||||||
list<uint8> backward;
|
|
||||||
list<uint8> lookLeft;
|
|
||||||
list<uint8> lookRight;
|
|
||||||
list<uint8> lookUp;
|
|
||||||
list<uint8> lookDown;
|
|
||||||
list<uint8> moveLeft;
|
|
||||||
list<uint8> moveRight;
|
|
||||||
list<uint8> moveUp;
|
|
||||||
list<uint8> moveDown;
|
|
||||||
list<uint8> firePrimary;
|
|
||||||
list<uint8> fireSecondary;
|
|
||||||
list<uint8> weaponNext;
|
|
||||||
list<uint8> weaponPrev;
|
|
||||||
list<uint8> toggleLights;
|
|
||||||
list<uint8> toggleFPS;
|
|
||||||
list<uint8> toggleConsole;
|
|
||||||
list<uint8> toggleMouseLook;
|
|
||||||
list<uint8> quickMouseLook;
|
|
||||||
list<uint8> rollLeft;
|
|
||||||
list<uint8> rollRight;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
389
src/keys.cpp
389
src/keys.cpp
@@ -19,6 +19,10 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
char OpenArena::KeyToASCII(Keys key, bool shift)
|
char OpenArena::KeyToASCII(Keys key, bool shift)
|
||||||
{
|
{
|
||||||
if(key == KEY_UNKNOWN)
|
if(key == KEY_UNKNOWN)
|
||||||
@@ -181,3 +185,388 @@ char OpenArena::KeyToASCII(Keys key, bool shift)
|
|||||||
}
|
}
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* OpenArena::GetKeyName(Keys key)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case KEY_UNKNOWN:
|
||||||
|
return "unknown";
|
||||||
|
case KEY_BUTTON0:
|
||||||
|
return "button0";
|
||||||
|
case KEY_BUTTON1:
|
||||||
|
return "button1";
|
||||||
|
case KEY_BUTTON2:
|
||||||
|
return "button2";
|
||||||
|
case KEY_BUTTON3:
|
||||||
|
return "button3";
|
||||||
|
case KEY_BUTTON4:
|
||||||
|
return "button4";
|
||||||
|
case KEY_LEFT:
|
||||||
|
return "left";
|
||||||
|
case KEY_RIGHT:
|
||||||
|
return "right";
|
||||||
|
case KEY_UP:
|
||||||
|
return "up";
|
||||||
|
case KEY_DOWN:
|
||||||
|
return "down";
|
||||||
|
case KEY_SPACE:
|
||||||
|
return "space";
|
||||||
|
case KEY_RETURN:
|
||||||
|
return "return";
|
||||||
|
case KEY_SHIFT:
|
||||||
|
return "shift";
|
||||||
|
case KEY_PAUSE:
|
||||||
|
return "pause";
|
||||||
|
case KEY_CONTROL:
|
||||||
|
return "ctrl";
|
||||||
|
case KEY_CAPITAL:
|
||||||
|
return "caps";
|
||||||
|
case KEY_ESCAPE:
|
||||||
|
return "esc";
|
||||||
|
case KEY_PRIOR:
|
||||||
|
return "pgup";
|
||||||
|
case KEY_NEXT:
|
||||||
|
return "pgdn";
|
||||||
|
case KEY_END:
|
||||||
|
return "end";
|
||||||
|
case KEY_HOME:
|
||||||
|
return "home";
|
||||||
|
case KEY_INSERT:
|
||||||
|
return "insert";
|
||||||
|
case KEY_DELETE:
|
||||||
|
return "del";
|
||||||
|
case KEY_LWIN:
|
||||||
|
return "leftwin";
|
||||||
|
case KEY_RWIN:
|
||||||
|
return "rightwin";
|
||||||
|
case KEY_APPS:
|
||||||
|
return "apps";
|
||||||
|
case KEY_NUMPAD0:
|
||||||
|
return "kp0";
|
||||||
|
case KEY_NUMPAD1:
|
||||||
|
return "kp1";
|
||||||
|
case KEY_NUMPAD2:
|
||||||
|
return "kp2";
|
||||||
|
case KEY_NUMPAD3:
|
||||||
|
return "kp3";
|
||||||
|
case KEY_NUMPAD4:
|
||||||
|
return "kp4";
|
||||||
|
case KEY_NUMPAD5:
|
||||||
|
return "kp5";
|
||||||
|
case KEY_NUMPAD6:
|
||||||
|
return "kp6";
|
||||||
|
case KEY_NUMPAD7:
|
||||||
|
return "kp7";
|
||||||
|
case KEY_NUMPAD8:
|
||||||
|
return "kp8";
|
||||||
|
case KEY_NUMPAD9:
|
||||||
|
return "kp9";
|
||||||
|
case KEY_MULTIPLY:
|
||||||
|
return "multiply";
|
||||||
|
case KEY_ADD:
|
||||||
|
return "plus";
|
||||||
|
case KEY_SUBTRACT:
|
||||||
|
return "minus";
|
||||||
|
case KEY_DIVIDE:
|
||||||
|
return "divide";
|
||||||
|
case KEY_F1:
|
||||||
|
return "f1";
|
||||||
|
case KEY_F2:
|
||||||
|
return "f2";
|
||||||
|
case KEY_F3:
|
||||||
|
return "f3";
|
||||||
|
case KEY_F4:
|
||||||
|
return "f4";
|
||||||
|
case KEY_F5:
|
||||||
|
return "f5";
|
||||||
|
case KEY_F6:
|
||||||
|
return "f6";
|
||||||
|
case KEY_F7:
|
||||||
|
return "f7";
|
||||||
|
case KEY_F8:
|
||||||
|
return "f8";
|
||||||
|
case KEY_F9:
|
||||||
|
return "f9";
|
||||||
|
case KEY_F10:
|
||||||
|
return "f10";
|
||||||
|
case KEY_F11:
|
||||||
|
return "f11";
|
||||||
|
case KEY_F12:
|
||||||
|
return "f12";
|
||||||
|
case KEY_NUMLOCK:
|
||||||
|
return "numlock";
|
||||||
|
case KEY_SCROLL:
|
||||||
|
return "scrolllock";
|
||||||
|
case KEY_SEPARATOR:
|
||||||
|
return "_separator";
|
||||||
|
case KEY_OEM_1:
|
||||||
|
return "semicolon";
|
||||||
|
case KEY_OEM_2:
|
||||||
|
return "slash";
|
||||||
|
case KEY_OEM_3:
|
||||||
|
return "tilde";
|
||||||
|
case KEY_OEM_4:
|
||||||
|
return "leftbracket";
|
||||||
|
case KEY_OEM_5:
|
||||||
|
return "backslash";
|
||||||
|
case KEY_OEM_6:
|
||||||
|
return "rightbracket";
|
||||||
|
case KEY_OEM_7:
|
||||||
|
return "quote";
|
||||||
|
case KEY_OEM_PERIOD:
|
||||||
|
return "period";
|
||||||
|
case KEY_OEM_PLUS:
|
||||||
|
return "equals";
|
||||||
|
case KEY_OEM_MINUS:
|
||||||
|
return "minus";
|
||||||
|
case KEY_OEM_COMMA:
|
||||||
|
return "comma";
|
||||||
|
case KEY_BACK:
|
||||||
|
return "backspace";
|
||||||
|
case KEY_TAB:
|
||||||
|
return "tab";
|
||||||
|
case KEY_0:
|
||||||
|
return "0";
|
||||||
|
case KEY_1:
|
||||||
|
return "1";
|
||||||
|
case KEY_2:
|
||||||
|
return "2";
|
||||||
|
case KEY_3:
|
||||||
|
return "3";
|
||||||
|
case KEY_4:
|
||||||
|
return "4";
|
||||||
|
case KEY_5:
|
||||||
|
return "5";
|
||||||
|
case KEY_6:
|
||||||
|
return "6";
|
||||||
|
case KEY_7:
|
||||||
|
return "7";
|
||||||
|
case KEY_8:
|
||||||
|
return "8";
|
||||||
|
case KEY_9:
|
||||||
|
return "9";
|
||||||
|
case KEY_A:
|
||||||
|
return "a";
|
||||||
|
case KEY_B:
|
||||||
|
return "b";
|
||||||
|
case KEY_C:
|
||||||
|
return "c";
|
||||||
|
case KEY_D:
|
||||||
|
return "d";
|
||||||
|
case KEY_E:
|
||||||
|
return "e";
|
||||||
|
case KEY_F:
|
||||||
|
return "f";
|
||||||
|
case KEY_G:
|
||||||
|
return "g";
|
||||||
|
case KEY_H:
|
||||||
|
return "h";
|
||||||
|
case KEY_I:
|
||||||
|
return "i";
|
||||||
|
case KEY_J:
|
||||||
|
return "j";
|
||||||
|
case KEY_K:
|
||||||
|
return "k";
|
||||||
|
case KEY_L:
|
||||||
|
return "l";
|
||||||
|
case KEY_M:
|
||||||
|
return "m";
|
||||||
|
case KEY_N:
|
||||||
|
return "n";
|
||||||
|
case KEY_O:
|
||||||
|
return "o";
|
||||||
|
case KEY_P:
|
||||||
|
return "p";
|
||||||
|
case KEY_Q:
|
||||||
|
return "q";
|
||||||
|
case KEY_R:
|
||||||
|
return "r";
|
||||||
|
case KEY_S:
|
||||||
|
return "s";
|
||||||
|
case KEY_T:
|
||||||
|
return "t";
|
||||||
|
case KEY_U:
|
||||||
|
return "u";
|
||||||
|
case KEY_V:
|
||||||
|
return "v";
|
||||||
|
case KEY_W:
|
||||||
|
return "w";
|
||||||
|
case KEY_X:
|
||||||
|
return "x";
|
||||||
|
case KEY_Y:
|
||||||
|
return "y";
|
||||||
|
case KEY_Z:
|
||||||
|
return "z";
|
||||||
|
case KEY_ALT_L:
|
||||||
|
return "leftalt";
|
||||||
|
case KEY_ALT_R:
|
||||||
|
return "rightalt";
|
||||||
|
case KEY_COMMAND:
|
||||||
|
return "command";
|
||||||
|
case KEY_ENTER:
|
||||||
|
return "enter";
|
||||||
|
case KEY_OPTION:
|
||||||
|
return "option";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenArena::Keys OpenArena::GetKey(const char* keyName)
|
||||||
|
{
|
||||||
|
string str = keyName;
|
||||||
|
if (str.length() > 1)
|
||||||
|
{
|
||||||
|
if (str.substr(0,2) == "up")
|
||||||
|
return OpenArena::KEY_UP;
|
||||||
|
else if (str.substr(0,4) == "down")
|
||||||
|
return OpenArena::KEY_DOWN;
|
||||||
|
else if (str.substr(0,3) == "esc")
|
||||||
|
return OpenArena::KEY_ESCAPE;
|
||||||
|
else if (str.substr(0,6) == "pageup")
|
||||||
|
return OpenArena::KEY_PRIOR;
|
||||||
|
else if (str.substr(0,8) == "pagedown")
|
||||||
|
return OpenArena::KEY_NEXT;
|
||||||
|
else if (str.substr(0,5) == "right")
|
||||||
|
return OpenArena::KEY_RIGHT;
|
||||||
|
else if (str.substr(0,4) == "left")
|
||||||
|
return OpenArena::KEY_LEFT;
|
||||||
|
else if (str.substr(0,5) == "space")
|
||||||
|
return OpenArena::KEY_SPACE;
|
||||||
|
else if (str.substr(0,6) == "mouse1")
|
||||||
|
return OpenArena::KEY_LBUTTON;
|
||||||
|
else if (str.substr(0,6) == "mouse2")
|
||||||
|
return OpenArena::KEY_RBUTTON;
|
||||||
|
else if (str.substr(0,6) == "mouse3")
|
||||||
|
return OpenArena::KEY_MBUTTON;
|
||||||
|
else if (str.substr(0,4) == "home")
|
||||||
|
return OpenArena::KEY_HOME;
|
||||||
|
else if (str.substr(0,3) == "end")
|
||||||
|
return OpenArena::KEY_END;
|
||||||
|
else if (str.substr(0,3) == "tab")
|
||||||
|
return OpenArena::KEY_TAB;
|
||||||
|
else if (str.substr(0,5) == "enter")
|
||||||
|
return OpenArena::KEY_RETURN;
|
||||||
|
else if (str.substr(0,6) == "insert")
|
||||||
|
return OpenArena::KEY_INSERT;
|
||||||
|
else if (str.substr(0,6) == "delete")
|
||||||
|
return OpenArena::KEY_DELETE;
|
||||||
|
else if (str.substr(0,7) == "control")
|
||||||
|
return OpenArena::KEY_CONTROL;
|
||||||
|
else if (str.substr(0,5) == "shift")
|
||||||
|
return OpenArena::KEY_SHIFT;
|
||||||
|
else if (str.substr(0,7) == "numpad0")
|
||||||
|
return OpenArena::KEY_NUMPAD0;
|
||||||
|
else if (str.substr(0,7) == "numpad1")
|
||||||
|
return OpenArena::KEY_NUMPAD1;
|
||||||
|
else if (str.substr(0,7) == "numpad2")
|
||||||
|
return OpenArena::KEY_NUMPAD2;
|
||||||
|
else if (str.substr(0,7) == "numpad3")
|
||||||
|
return OpenArena::KEY_NUMPAD3;
|
||||||
|
else if (str.substr(0,7) == "numpad4")
|
||||||
|
return OpenArena::KEY_NUMPAD4;
|
||||||
|
else if (str.substr(0,7) == "numpad5")
|
||||||
|
return OpenArena::KEY_NUMPAD5;
|
||||||
|
else if (str.substr(0,7) == "numpad6")
|
||||||
|
return OpenArena::KEY_NUMPAD6;
|
||||||
|
else if (str.substr(0,7) == "numpad7")
|
||||||
|
return OpenArena::KEY_NUMPAD7;
|
||||||
|
else if (str.substr(0,7) == "numpad8")
|
||||||
|
return OpenArena::KEY_NUMPAD8;
|
||||||
|
else if (str.substr(0,7) == "numpad9")
|
||||||
|
return OpenArena::KEY_NUMPAD9;
|
||||||
|
else if (str.substr(0,9) == "separator")
|
||||||
|
return OpenArena::KEY_SEPARATOR;
|
||||||
|
else if (str.substr(0,4) == "lwin")
|
||||||
|
return OpenArena::KEY_LWIN;
|
||||||
|
else if (str.substr(0,4) == "rwin")
|
||||||
|
return OpenArena::KEY_RWIN;
|
||||||
|
else if (str.substr(0,4) == "apps")
|
||||||
|
return OpenArena::KEY_APPS;
|
||||||
|
else if (str.substr(0,7) == "numpad*")
|
||||||
|
return OpenArena::KEY_MULTIPLY;
|
||||||
|
else if (str.substr(0,7) == "numpad+")
|
||||||
|
return OpenArena::KEY_ADD;
|
||||||
|
else if (str.substr(0,7) == "numpad/")
|
||||||
|
return OpenArena::KEY_DIVIDE;
|
||||||
|
else if (str.substr(0,7) == "numpad-")
|
||||||
|
return OpenArena::KEY_SUBTRACT;
|
||||||
|
else if (str.substr(0,6) == "scroll")
|
||||||
|
return OpenArena::KEY_SCROLL;
|
||||||
|
else if (str.substr(0,7) == "numlock")
|
||||||
|
return OpenArena::KEY_NUMLOCK;
|
||||||
|
else if (str.substr(0,5) == "pause")
|
||||||
|
return OpenArena::KEY_PAUSE;
|
||||||
|
else if (str.substr(0,8) == "capslock")
|
||||||
|
return OpenArena::KEY_CAPITAL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*uncomment this to enable f1 as a mappable key
|
||||||
|
else if(str.substr(0,2) == "f1")
|
||||||
|
return OpenArena::KEY_F1;
|
||||||
|
*/
|
||||||
|
|
||||||
|
else if (str.substr(0,2) == "f2")
|
||||||
|
return OpenArena::KEY_F2;
|
||||||
|
else if (str.substr(0,2) == "f3")
|
||||||
|
return OpenArena::KEY_F3;
|
||||||
|
else if (str.substr(0,2) == "f4")
|
||||||
|
return OpenArena::KEY_F4;
|
||||||
|
else if (str.substr(0,2) == "f5")
|
||||||
|
return OpenArena::KEY_F5;
|
||||||
|
else if (str.substr(0,2) == "f6")
|
||||||
|
return OpenArena::KEY_F6;
|
||||||
|
else if (str.substr(0,2) == "f7")
|
||||||
|
return OpenArena::KEY_F7;
|
||||||
|
else if (str.substr(0,2) == "f8")
|
||||||
|
return OpenArena::KEY_F8;
|
||||||
|
else if (str.substr(0,2) == "f9")
|
||||||
|
return OpenArena::KEY_F9;
|
||||||
|
else if (str.substr(0,2) == "f10")
|
||||||
|
return OpenArena::KEY_F10;
|
||||||
|
else if (str.substr(0,2) == "f11")
|
||||||
|
return OpenArena::KEY_F11;
|
||||||
|
else if (str.substr(0,2) == "f12")
|
||||||
|
return OpenArena::KEY_F12;
|
||||||
|
//Add Game specific keys here and e-mail headhunter45@hotmail.com subject OpenArena keys so I can add them please
|
||||||
|
else if (str.substr(0,4) == "null")
|
||||||
|
return OpenArena::KEY_UNKNOWN;
|
||||||
|
else
|
||||||
|
return OpenArena::KEY_UNKNOWN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(str[0] == '~' || str[0] == '`')
|
||||||
|
return OpenArena::KEY_OEM_3;
|
||||||
|
else if (str[0] == '?' || str[0] == '/')
|
||||||
|
return OpenArena::KEY_OEM_2;
|
||||||
|
else if (str[0] == '.' || str[0] == '>')
|
||||||
|
return OpenArena::KEY_OEM_PERIOD;
|
||||||
|
else if (str[0] == '+' || str[0] == '=')
|
||||||
|
return OpenArena::KEY_OEM_PLUS;
|
||||||
|
else if (str[0] == ';' || str[0] == ':')
|
||||||
|
return OpenArena::KEY_OEM_1;
|
||||||
|
else if (str[0] == ',' || str[0] == '<')
|
||||||
|
return OpenArena::KEY_OEM_COMMA;
|
||||||
|
else if (str[0] == '-' || str[0] == '_')
|
||||||
|
return OpenArena::KEY_OEM_MINUS;
|
||||||
|
else if (str[0] == '[' || str[0] == '{')
|
||||||
|
return OpenArena::KEY_OEM_4;
|
||||||
|
else if (str[0] == ']' || str[0] == '}')
|
||||||
|
return OpenArena::KEY_OEM_6;
|
||||||
|
else if (str[0] == '\\' || str[0] == '|')
|
||||||
|
return OpenArena::KEY_OEM_5;
|
||||||
|
else if (str[0] == '\'' || str[0] == '"')
|
||||||
|
return OpenArena::KEY_OEM_7;
|
||||||
|
else if (isalpha(str[0]))
|
||||||
|
return (OpenArena::Keys)(toupper(str[0]) - 'A' + OpenArena::KEY_A);
|
||||||
|
else if(isdigit(str[0]))
|
||||||
|
return (OpenArena::Keys)(str[0] - '0' + OpenArena::KEY_0);
|
||||||
|
else
|
||||||
|
return OpenArena::KEY_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
src/keys.h
10
src/keys.h
@@ -142,7 +142,12 @@ namespace OpenArena
|
|||||||
KEY_W,
|
KEY_W,
|
||||||
KEY_X,
|
KEY_X,
|
||||||
KEY_Y,
|
KEY_Y,
|
||||||
KEY_Z
|
KEY_Z,
|
||||||
|
KEY_ALT_L,
|
||||||
|
KEY_ALT_R,
|
||||||
|
KEY_ENTER,
|
||||||
|
KEY_COMMAND,
|
||||||
|
KEY_OPTION
|
||||||
};
|
};
|
||||||
/*!
|
/*!
|
||||||
* \brief
|
* \brief
|
||||||
@@ -208,5 +213,8 @@ namespace OpenArena
|
|||||||
* Separate items with the '|' character.
|
* Separate items with the '|' character.
|
||||||
*/
|
*/
|
||||||
char KeyToASCII(Keys key, bool shift);
|
char KeyToASCII(Keys key, bool shift);
|
||||||
|
const char* GetKeyName(Keys key);
|
||||||
|
OpenArena::Keys GetKey(const char* keyName);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
383
src/level.cpp
383
src/level.cpp
@@ -54,8 +54,9 @@ using namespace std;
|
|||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
Level::Level()
|
Level::Level(EventManager* eventManager)
|
||||||
{
|
{
|
||||||
|
_eventManager = eventManager;
|
||||||
_window = NULL;
|
_window = NULL;
|
||||||
textureNames = NULL;
|
textureNames = NULL;
|
||||||
numTextures = 0;
|
numTextures = 0;
|
||||||
@@ -570,157 +571,18 @@ namespace OpenArena
|
|||||||
else if(command == "bind")
|
else if(command == "bind")
|
||||||
{
|
{
|
||||||
command = tolower(word(cmd, ++i));
|
command = tolower(word(cmd, ++i));
|
||||||
|
string key = tolower(word(cmd, ++i));
|
||||||
if(command == "forward")
|
if(ControlScheme::GetAction(command.c_str())==OpenArena::ControlScheme::ACTION_NONE)
|
||||||
{
|
{
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FORWARD, KeyName(word(cmd, ++i))))
|
ConsolePrint("No action identified by " + command);
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action forward");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(command == "backward")
|
else if (GetKey(key.c_str()) == OpenArena::KEY_UNKNOWN)
|
||||||
{
|
{
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_BACKWARD, KeyName(word(cmd, ++i))))
|
ConsolePrint("No key identified by " + key);
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action backward");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "lookleft")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKLEFT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action lookleft");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "lookright")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKRIGHT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action lookright");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "lookup")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKUP, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action lookup");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "lookdown")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKDOWN, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action lookdown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "moveup")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVEUP, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action moveup");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "movedown")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVEDOWN, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action movedown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "moveleft")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVELEFT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action moveleft");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "moveright")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVERIGHT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action moveright");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "fireprimary")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FIREPRIMARY, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action fireprimary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "firesecondary")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FIRESECONDARY, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action firesecondary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "weapnext")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_WEAPONNEXT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action weapnext");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "weapprev")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_WEAPONPREV, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action weapprev");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "togglelights" || command == "togglelighting")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_LIGHTS, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action togglelights");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "togglefps")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_FPS, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action togglefps");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "toggleconsole")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action toggleconsole");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "togglemouselook")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_MOUSELOOK, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action togglemouselook");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "quickmouselook")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_QUICKMOUSELOOK, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action quickmouselook");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "rollleft")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_ROLLLEFT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action rollleft");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(command == "rollright")
|
|
||||||
{
|
|
||||||
if(!defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_ROLLRIGHT, KeyName(word(cmd, ++i))))
|
|
||||||
{
|
|
||||||
ConsolePrint("Couldn't bind " + word(cmd, i) + " to action rollright");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConsolePrint("No action identified by " + command);
|
defaultPlayer[0].controls.Bind(GetKey(key.c_str()), ControlScheme::GetAction(command.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(command == "map" || command == "map_load")
|
else if(command == "map" || command == "map_load")
|
||||||
@@ -740,11 +602,11 @@ namespace OpenArena
|
|||||||
|
|
||||||
if(command == "all")
|
if(command == "all")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.ClearControlScheme();
|
defaultPlayer[0].controls.UnBindAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Unbind(KeyName(command));
|
defaultPlayer[0].controls.UnBind(GetKey(command.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(command == "exec" || command == "config_load")
|
else if(command == "exec" || command == "config_load")
|
||||||
@@ -814,11 +676,10 @@ namespace OpenArena
|
|||||||
string cmd = lpCmdLine;
|
string cmd = lpCmdLine;
|
||||||
string command;
|
string command;
|
||||||
|
|
||||||
uint32 i=0xFFFFFFFF;
|
uint32 i=0;
|
||||||
while(word(cmd, ++i) != "")
|
command = word(cmd, i);
|
||||||
|
while(command != "")
|
||||||
{
|
{
|
||||||
command = word(cmd, i);
|
|
||||||
|
|
||||||
if(command == "+set")
|
if(command == "+set")
|
||||||
{
|
{
|
||||||
command = tolower(word(cmd, ++i));
|
command = tolower(word(cmd, ++i));
|
||||||
@@ -842,6 +703,9 @@ namespace OpenArena
|
|||||||
else if(command == "game")
|
else if(command == "game")
|
||||||
{
|
{
|
||||||
gamedir= word(cmd, ++i);
|
gamedir= word(cmd, ++i);
|
||||||
|
if(gamedir[gamedir.length()-1] != '/'){
|
||||||
|
gamedir = gamedir + '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(command == "+bind")
|
else if(command == "+bind")
|
||||||
@@ -850,79 +714,79 @@ namespace OpenArena
|
|||||||
|
|
||||||
if(command == "forward")
|
if(command == "forward")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FORWARD, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FORWARD);
|
||||||
}
|
}
|
||||||
else if(command == "backward")
|
else if(command == "backward")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_BACKWARD, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_BACKWARD);
|
||||||
}
|
}
|
||||||
else if(command == "lookleft")
|
else if(command == "lookleft")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKLEFT, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKLEFT);
|
||||||
}
|
}
|
||||||
else if(command == "lookright")
|
else if(command == "lookright")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKRIGHT, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKRIGHT);
|
||||||
}
|
}
|
||||||
else if(command == "lookup")
|
else if(command == "lookup")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKUP, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKUP);
|
||||||
}
|
}
|
||||||
else if(command == "lookdown")
|
else if(command == "lookdown")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_LOOKDOWN, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKDOWN);
|
||||||
}
|
}
|
||||||
else if(command == "moveup")
|
else if(command == "moveup")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVEUP, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVEUP);
|
||||||
}
|
}
|
||||||
else if(command == "movedown")
|
else if(command == "movedown")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVEDOWN, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVEDOWN);
|
||||||
}
|
}
|
||||||
else if(command == "moveleft")
|
else if(command == "moveleft")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVELEFT, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVELEFT);
|
||||||
}
|
}
|
||||||
else if(command == "moveright")
|
else if(command == "moveright")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_MOVERIGHT, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVERIGHT);
|
||||||
}
|
}
|
||||||
else if(command == "fireprimary")
|
else if(command == "fireprimary")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FIREPRIMARY, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FIREPRIMARY);
|
||||||
}
|
}
|
||||||
else if(command == "firesecondary")
|
else if(command == "firesecondary")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_FIRESECONDARY, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FIRESECONDARY);
|
||||||
}
|
}
|
||||||
else if(command == "weapnext")
|
else if(command == "weapnext")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_WEAPONNEXT, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_WEAPONNEXT);
|
||||||
}
|
}
|
||||||
else if(command == "weapprev")
|
else if(command == "weapprev")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_WEAPONPREV, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_WEAPONPREV);
|
||||||
}
|
}
|
||||||
else if(command == "togglelights" || command == "togglelighting")
|
else if(command == "togglelights" || command == "togglelighting")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_LIGHTS, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_LIGHTS);
|
||||||
}
|
}
|
||||||
else if(command == "togglefps")
|
else if(command == "togglefps")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_FPS, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_FPS);
|
||||||
}
|
}
|
||||||
else if(command == "toggleconsole")
|
else if(command == "toggleconsole")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE);
|
||||||
}
|
}
|
||||||
else if(command == "togglemouselook")
|
else if(command == "togglemouselook")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_TOGGLE_MOUSELOOK, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_MOUSELOOK);
|
||||||
}
|
}
|
||||||
else if(command == "quickmouselook")
|
else if(command == "quickmouselook")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Bind(OpenArena::ControlScheme::ACTION_QUICKMOUSELOOK, KeyName(word(cmd, ++i)));
|
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_QUICKMOUSELOOK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(command == "+map" || command == "+map_load")
|
else if(command == "+map" || command == "+map_load")
|
||||||
@@ -937,11 +801,11 @@ namespace OpenArena
|
|||||||
|
|
||||||
if(command == "all")
|
if(command == "all")
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.ClearControlScheme();
|
defaultPlayer[0].controls.UnBindAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
defaultPlayer[0].controls.Unbind(KeyName(command));
|
defaultPlayer[0].controls.UnBind(GetKey(command.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(command == "+exec" || command == "+config_load")
|
else if(command == "+exec" || command == "+config_load")
|
||||||
@@ -959,7 +823,8 @@ namespace OpenArena
|
|||||||
command = tolower(word(cmd, ++i));
|
command = tolower(word(cmd, ++i));
|
||||||
SaveConfig(command);
|
SaveConfig(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command = word(cmd, ++i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,173 +899,7 @@ namespace OpenArena
|
|||||||
output << "set maxfps " << maxFPS << endl;
|
output << "set maxfps " << maxFPS << endl;
|
||||||
|
|
||||||
//Control Scheme
|
//Control Scheme
|
||||||
//output << " bind " << action << keyname << endl;
|
defaultPlayer->controls.WriteToStream(output);
|
||||||
if(!defaultPlayer->controls.backward.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.backward.FirstPosition();
|
|
||||||
output << "bind backward " << string(KeyString(defaultPlayer->controls.backward.Retrieve())) << endl;
|
|
||||||
while(defaultPlayer->controls.backward.NextPosition())
|
|
||||||
output << "bind backward " << KeyString(defaultPlayer->controls.backward.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.firePrimary.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.firePrimary.FirstPosition();
|
|
||||||
output << "bind firePrimary " << KeyString(defaultPlayer->controls.firePrimary.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.firePrimary.NextPosition())
|
|
||||||
output << "bind firePrimary " << KeyString(defaultPlayer->controls.firePrimary.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.fireSecondary.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.fireSecondary.FirstPosition();
|
|
||||||
output << "bind fireSecondary " << KeyString(defaultPlayer->controls.fireSecondary.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.fireSecondary.NextPosition())
|
|
||||||
output << "bind fireSecondary " << KeyString(defaultPlayer->controls.fireSecondary.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.forward.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.forward.FirstPosition();
|
|
||||||
output << "bind forward " << KeyString(defaultPlayer->controls.forward.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.forward.NextPosition())
|
|
||||||
output << "bind forward " << KeyString(defaultPlayer->controls.forward.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.lookDown.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.lookDown.FirstPosition();
|
|
||||||
output << "bind lookDown " << KeyString(defaultPlayer->controls.lookDown.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.lookDown.NextPosition())
|
|
||||||
output << "bind lookDown " << KeyString(defaultPlayer->controls.lookDown.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.lookLeft.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.lookLeft.FirstPosition();
|
|
||||||
output << "bind lookLeft " << KeyString(defaultPlayer->controls.lookLeft.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.lookLeft.NextPosition())
|
|
||||||
output << "bind lookLeft " << KeyString(defaultPlayer->controls.lookLeft.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.lookRight.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.lookRight.FirstPosition();
|
|
||||||
output << "bind lookRight " << KeyString(defaultPlayer->controls.lookRight.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.lookRight.NextPosition())
|
|
||||||
output << "bind lookRight " << KeyString(defaultPlayer->controls.lookRight.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
if(!defaultPlayer->controls.lookUp.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.lookUp.FirstPosition();
|
|
||||||
output << "bind lookUp " << KeyString(defaultPlayer->controls.lookUp.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.lookUp.NextPosition())
|
|
||||||
output << "bind lookUp " << KeyString(defaultPlayer->controls.lookUp.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.moveDown.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.moveDown.FirstPosition();
|
|
||||||
output << "bind moveDown " << KeyString(defaultPlayer->controls.moveDown.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.moveDown.NextPosition())
|
|
||||||
output << "bind moveDown " << KeyString(defaultPlayer->controls.moveDown.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.moveLeft.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.moveLeft.FirstPosition();
|
|
||||||
output << "bind moveLeft " << KeyString(defaultPlayer->controls.moveLeft.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.moveLeft.NextPosition())
|
|
||||||
output << "bind moveLeft " << KeyString(defaultPlayer->controls.moveLeft.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.moveRight.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.moveRight.FirstPosition();
|
|
||||||
output << "bind moveRight " << KeyString(defaultPlayer->controls.moveRight.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.moveRight.NextPosition())
|
|
||||||
output << "bind moveRight " << KeyString(defaultPlayer->controls.moveRight.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.moveUp.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.moveUp.FirstPosition();
|
|
||||||
output << "bind moveUp " << KeyString(defaultPlayer->controls.moveUp.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.moveUp.NextPosition())
|
|
||||||
output << "bind moveUp " << KeyString(defaultPlayer->controls.moveUp.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.quickMouseLook.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.quickMouseLook.FirstPosition();
|
|
||||||
output << "bind quickMouseLook " << KeyString(defaultPlayer->controls.quickMouseLook.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.quickMouseLook.NextPosition())
|
|
||||||
output << "bind quickMouseLook " << KeyString(defaultPlayer->controls.quickMouseLook.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.rollLeft.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.rollLeft.FirstPosition();
|
|
||||||
output << "bind rollLeft " << KeyString(defaultPlayer->controls.rollLeft.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.rollLeft.NextPosition())
|
|
||||||
output << "bind rollLeft " << KeyString(defaultPlayer->controls.rollLeft.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.rollRight.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.rollRight.FirstPosition();
|
|
||||||
output << "bind rollRight " << KeyString(defaultPlayer->controls.rollRight.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.rollRight.NextPosition())
|
|
||||||
output << "bind rollRight " << KeyString(defaultPlayer->controls.rollRight.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.toggleConsole.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.toggleConsole.FirstPosition();
|
|
||||||
output << "bind toggleConsole " << KeyString(defaultPlayer->controls.toggleConsole.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.toggleConsole.NextPosition())
|
|
||||||
output << "bind toggleConsole " << KeyString(defaultPlayer->controls.toggleConsole.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.toggleFPS.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.toggleFPS.FirstPosition();
|
|
||||||
output << "bind toggleFPS " << KeyString(defaultPlayer->controls.toggleFPS.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.toggleFPS.NextPosition())
|
|
||||||
output << "bind toggleFPS " << KeyString(defaultPlayer->controls.toggleFPS.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.toggleLights.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.toggleLights.FirstPosition();
|
|
||||||
output << "bind toggleLights " << KeyString(defaultPlayer->controls.toggleLights.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.toggleLights.NextPosition())
|
|
||||||
output << "bind toggleLights " << KeyString(defaultPlayer->controls.toggleLights.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.toggleMouseLook.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.toggleMouseLook.FirstPosition();
|
|
||||||
output << "bind toggleMouseLook " << KeyString(defaultPlayer->controls.toggleMouseLook.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.toggleMouseLook.NextPosition())
|
|
||||||
output << "bind toggleMouseLook " << KeyString(defaultPlayer->controls.toggleMouseLook.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.weaponNext.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.weaponNext.FirstPosition();
|
|
||||||
output << "bind weaponNext " << KeyString(defaultPlayer->controls.weaponNext.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.weaponNext.NextPosition())
|
|
||||||
output << "bind weaponNext " << KeyString(defaultPlayer->controls.weaponNext.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!defaultPlayer->controls.weaponPrev.IsEmpty())
|
|
||||||
{
|
|
||||||
defaultPlayer->controls.weaponPrev.FirstPosition();
|
|
||||||
output << "bind weaponPrev " << KeyString(defaultPlayer->controls.weaponPrev.Retrieve()) << endl;
|
|
||||||
while(defaultPlayer->controls.weaponPrev.NextPosition())
|
|
||||||
output << "bind weaponPrev " << KeyString(defaultPlayer->controls.weaponPrev.Retrieve()) << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::Print(int x, int y, const char* str, unsigned int set)
|
void Level::Print(int x, int y, const char* str, unsigned int set)
|
||||||
@@ -1225,7 +924,7 @@ namespace OpenArena
|
|||||||
{
|
{
|
||||||
consoleHistory[0] = Left(consoleHistory[0], consoleHistory[0].length()-1);
|
consoleHistory[0] = Left(consoleHistory[0], consoleHistory[0].length()-1);
|
||||||
}
|
}
|
||||||
else if(!(defaultPlayer->controls.toggleConsole.Contains(newChar)))
|
else if(!(defaultPlayer->controls.IsBound(GetKey(&newChar), ControlScheme::ACTION_TOGGLE_CONSOLE)))
|
||||||
{
|
{
|
||||||
consoleHistory[0] = consoleHistory[0] + newChar;
|
consoleHistory[0] = consoleHistory[0] + newChar;
|
||||||
/*
|
/*
|
||||||
|
|||||||
375
src/level.h
375
src/level.h
@@ -58,393 +58,42 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "strmanip.h"
|
#include "strmanip.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
#include "EventManager.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using OpenArena::Triangle;
|
using OpenArena::Triangle;
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for piover180 here.
|
|
||||||
*
|
|
||||||
* Write detailed description for piover180 here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for piover180 here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const float piover180 = 0.0174532925f;
|
const float piover180 = 0.0174532925f;
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for DEFAULT_TEXTURE_NAME here.
|
|
||||||
*
|
|
||||||
* Write detailed description for DEFAULT_TEXTURE_NAME here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for DEFAULT_TEXTURE_NAME here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp";
|
const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp";
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for MAX_CONSOLE_LINES here.
|
|
||||||
*
|
|
||||||
* Write detailed description for MAX_CONSOLE_LINES here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for MAX_CONSOLE_LINES here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console
|
const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for MAX_CONSOLE_HISTORY_LINES here.
|
|
||||||
*
|
|
||||||
* Write detailed description for MAX_CONSOLE_HISTORY_LINES here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for MAX_CONSOLE_HISTORY_LINES here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history
|
const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for MAX_CONSOLE_OUTPUT_LINES here.
|
|
||||||
*
|
|
||||||
* Write detailed description for MAX_CONSOLE_OUTPUT_LINES here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for MAX_CONSOLE_OUTPUT_LINES here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES;
|
const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES;
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for MAX_OUTPUT_TEXT_LINES here.
|
|
||||||
*
|
|
||||||
* Write detailed description for MAX_OUTPUT_TEXT_LINES here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for MAX_OUTPUT_TEXT_LINES here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen
|
const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for GL_MY_TEXTURE_CONSOLEBACKGROUND here.
|
|
||||||
*/
|
|
||||||
enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES};
|
enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES};
|
||||||
|
|
||||||
class Level
|
class Level
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
Level(EventManager* eventManager);
|
||||||
* \brief
|
|
||||||
* Write brief comment for Level here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Level here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Level here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
Level();
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for ~Level here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for ~Level here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for ~Level here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
~Level();
|
~Level();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for LoadMap here.
|
|
||||||
*
|
|
||||||
* \param mapname
|
|
||||||
* Description of parameter mapname.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for LoadMap here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for LoadMap here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
bool LoadMap(string mapname);
|
bool LoadMap(string mapname);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for LoadMap here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for LoadMap here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for LoadMap here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
bool LoadMap();
|
bool LoadMap();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SaveMap here.
|
|
||||||
*
|
|
||||||
* \param mapname
|
|
||||||
* Description of parameter mapname.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SaveMap here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SaveMap here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SaveMap(string mapname);
|
void SaveMap(string mapname);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \param cfgname
|
|
||||||
* Description of parameter cfgname.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
bool LoadConfig(string cfgname);
|
bool LoadConfig(string cfgname);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for LoadConfig here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void LoadConfig();
|
void LoadConfig();
|
||||||
void SaveConfig(string cfgname);
|
void SaveConfig(string cfgname);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Execute here.
|
|
||||||
*
|
|
||||||
* \param cmd
|
|
||||||
* Description of parameter cmd.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Execute here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Execute here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Execute(string cmd);
|
void Execute(string cmd);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for LoadGLTextures here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for LoadGLTextures here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for LoadGLTextures here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void LoadGLTextures();
|
void LoadGLTextures();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Render here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Render here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Render here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Render();
|
void Render();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for UnloadMap here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for UnloadMap here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for UnloadMap here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void UnloadMap();
|
void UnloadMap();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for UpdateConsole here.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for UpdateConsole here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for UpdateConsole here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void UpdateConsole(char);
|
void UpdateConsole(char);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for FPS here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for FPS here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for FPS here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
uint32 FPS();
|
uint32 FPS();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for ParseCmds here.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for ParseCmds here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for ParseCmds here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void ParseCmds(const char*);
|
void ParseCmds(const char*);
|
||||||
void Print(int x, int y, const char* string, unsigned int set);
|
void Print(int x, int y, const char* string, unsigned int set);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SetWindow here.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SetWindow here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SetWindow here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SetWindow(Window*);
|
void SetWindow(Window*);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for GetWindow here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for GetWindow here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for GetWindow here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
Window* GetWindow();
|
Window* GetWindow();
|
||||||
|
|
||||||
/*Not Yet Implemented
|
/*Not Yet Implemented
|
||||||
@@ -482,28 +131,10 @@ namespace OpenArena
|
|||||||
Texture menuTextures[NUM_MENU_TEXTURES];
|
Texture menuTextures[NUM_MENU_TEXTURES];
|
||||||
Window* _window;
|
Window* _window;
|
||||||
|
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for ConsolePrint here.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for ConsolePrint here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for ConsolePrint here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void ConsolePrint(string);
|
void ConsolePrint(string);
|
||||||
private:
|
private:
|
||||||
|
EventManager* _eventManager;
|
||||||
string consoleHistory[MAX_CONSOLE_HISTORY_LINES];
|
string consoleHistory[MAX_CONSOLE_HISTORY_LINES];
|
||||||
string consoleOutput[MAX_CONSOLE_OUTPUT_LINES];
|
string consoleOutput[MAX_CONSOLE_OUTPUT_LINES];
|
||||||
string outputText[MAX_OUTPUT_TEXT_LINES];
|
string outputText[MAX_OUTPUT_TEXT_LINES];
|
||||||
|
|||||||
921
src/macosx.cpp
921
src/macosx.cpp
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@
|
|||||||
#include <GL/gl.h> // Header file for OpenGL32 library
|
#include <GL/gl.h> // Header file for OpenGL32 library
|
||||||
#include <GL/glu.h> // Header file for Glu32 library
|
#include <GL/glu.h> // Header file for Glu32 library
|
||||||
#elif defined USE_AGL
|
#elif defined USE_AGL
|
||||||
#error unimplemented method
|
#include "mygl.h"
|
||||||
#elif defined USE_CGL
|
#elif defined USE_CGL
|
||||||
#error unimplemented method
|
#error unimplemented method
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
@@ -130,6 +130,6 @@ int InitGL(); // All setup for OpenGL goes here
|
|||||||
* Separate items with the '|' character.
|
* Separate items with the '|' character.
|
||||||
*/
|
*/
|
||||||
void ReSizeGLScene(GLsizei width, GLsizei height); // Resize and initialize the GL window
|
void ReSizeGLScene(GLsizei width, GLsizei height); // Resize and initialize the GL window
|
||||||
int DrawGLScene();
|
int DrawGLScene(OpenArena::Level* level);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -82,4 +82,4 @@ namespace OpenArena
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenArena::Window g_Screen;
|
OpenArena::Window* g_Screen = new OpenArena::Window();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ using namespace std;
|
|||||||
//These this is windows specific
|
//These this is windows specific
|
||||||
static HINSTANCE hInstance; // Application instance
|
static HINSTANCE hInstance; // Application instance
|
||||||
#endif
|
#endif
|
||||||
extern OpenArena::Window g_Screen;
|
extern OpenArena::Window* g_Screen;
|
||||||
//This doesn't need to be here I think
|
//This doesn't need to be here I think
|
||||||
//int InitGL(GLvoid);
|
//int InitGL(GLvoid);
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
|
|||||||
105
src/player.h
105
src/player.h
@@ -24,121 +24,34 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "EventManager.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "ctrls.h"
|
#include "ctrls.h"
|
||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Player here.
|
|
||||||
*
|
|
||||||
* Write detailed description for Player here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Player here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Load here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Load here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Load here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Load();
|
void Load();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Save here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Save here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Save here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Save();
|
void Save();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for CreateCharacter here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for CreateCharacter here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for CreateCharacter here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void CreateCharacter();
|
void CreateCharacter();
|
||||||
//void FirePrimary(ENTITY& ent);
|
|
||||||
//void FireSecondary();
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for AddItem here.
|
|
||||||
*
|
|
||||||
* \param item
|
|
||||||
* Description of parameter item.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for AddItem here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for AddItem here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void AddItem(unsigned int item);
|
void AddItem(unsigned int item);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for RemoveItem here.
|
|
||||||
*
|
|
||||||
* \param item
|
|
||||||
* Description of parameter item.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for RemoveItem here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for RemoveItem here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void RemoveItem(unsigned int item);
|
void RemoveItem(unsigned int item);
|
||||||
|
|
||||||
ControlScheme controls;
|
ControlScheme controls;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
EventManager eventManager;
|
||||||
|
|
||||||
|
class EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
165
src/strmanip.cpp
165
src/strmanip.cpp
@@ -240,160 +240,6 @@ string KeyString(uint8 key)
|
|||||||
return "null";
|
return "null";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
uint8 KeyName(std::string str)
|
|
||||||
{
|
|
||||||
if (str.length() > 1)
|
|
||||||
{
|
|
||||||
if (str.substr(0,2) == "up")
|
|
||||||
return OpenArena::KEY_UP;
|
|
||||||
else if (str.substr(0,4) == "down")
|
|
||||||
return OpenArena::KEY_DOWN;
|
|
||||||
else if (str.substr(0,3) == "esc")
|
|
||||||
return OpenArena::KEY_ESCAPE;
|
|
||||||
else if (str.substr(0,6) == "pageup")
|
|
||||||
return OpenArena::KEY_PRIOR;
|
|
||||||
else if (str.substr(0,8) == "pagedown")
|
|
||||||
return OpenArena::KEY_NEXT;
|
|
||||||
else if (str.substr(0,5) == "right")
|
|
||||||
return OpenArena::KEY_RIGHT;
|
|
||||||
else if (str.substr(0,4) == "left")
|
|
||||||
return OpenArena::KEY_LEFT;
|
|
||||||
else if (str.substr(0,5) == "space")
|
|
||||||
return OpenArena::KEY_SPACE;
|
|
||||||
else if (str.substr(0,6) == "mouse1")
|
|
||||||
return OpenArena::KEY_LBUTTON;
|
|
||||||
else if (str.substr(0,6) == "mouse2")
|
|
||||||
return OpenArena::KEY_RBUTTON;
|
|
||||||
else if (str.substr(0,6) == "mouse3")
|
|
||||||
return OpenArena::KEY_MBUTTON;
|
|
||||||
else if (str.substr(0,4) == "home")
|
|
||||||
return OpenArena::KEY_HOME;
|
|
||||||
else if (str.substr(0,3) == "end")
|
|
||||||
return OpenArena::KEY_END;
|
|
||||||
else if (str.substr(0,3) == "tab")
|
|
||||||
return OpenArena::KEY_TAB;
|
|
||||||
else if (str.substr(0,5) == "enter")
|
|
||||||
return OpenArena::KEY_RETURN;
|
|
||||||
else if (str.substr(0,6) == "insert")
|
|
||||||
return OpenArena::KEY_INSERT;
|
|
||||||
else if (str.substr(0,6) == "delete")
|
|
||||||
return OpenArena::KEY_DELETE;
|
|
||||||
else if (str.substr(0,7) == "control")
|
|
||||||
return OpenArena::KEY_CONTROL;
|
|
||||||
else if (str.substr(0,5) == "shift")
|
|
||||||
return OpenArena::KEY_SHIFT;
|
|
||||||
else if (str.substr(0,7) == "numpad0")
|
|
||||||
return OpenArena::KEY_NUMPAD0;
|
|
||||||
else if (str.substr(0,7) == "numpad1")
|
|
||||||
return OpenArena::KEY_NUMPAD1;
|
|
||||||
else if (str.substr(0,7) == "numpad2")
|
|
||||||
return OpenArena::KEY_NUMPAD2;
|
|
||||||
else if (str.substr(0,7) == "numpad3")
|
|
||||||
return OpenArena::KEY_NUMPAD3;
|
|
||||||
else if (str.substr(0,7) == "numpad4")
|
|
||||||
return OpenArena::KEY_NUMPAD4;
|
|
||||||
else if (str.substr(0,7) == "numpad5")
|
|
||||||
return OpenArena::KEY_NUMPAD5;
|
|
||||||
else if (str.substr(0,7) == "numpad6")
|
|
||||||
return OpenArena::KEY_NUMPAD6;
|
|
||||||
else if (str.substr(0,7) == "numpad7")
|
|
||||||
return OpenArena::KEY_NUMPAD7;
|
|
||||||
else if (str.substr(0,7) == "numpad8")
|
|
||||||
return OpenArena::KEY_NUMPAD8;
|
|
||||||
else if (str.substr(0,7) == "numpad9")
|
|
||||||
return OpenArena::KEY_NUMPAD9;
|
|
||||||
else if (str.substr(0,9) == "separator")
|
|
||||||
return OpenArena::KEY_SEPARATOR;
|
|
||||||
else if (str.substr(0,4) == "lwin")
|
|
||||||
return OpenArena::KEY_LWIN;
|
|
||||||
else if (str.substr(0,4) == "rwin")
|
|
||||||
return OpenArena::KEY_RWIN;
|
|
||||||
else if (str.substr(0,4) == "apps")
|
|
||||||
return OpenArena::KEY_APPS;
|
|
||||||
else if (str.substr(0,7) == "numpad*")
|
|
||||||
return OpenArena::KEY_MULTIPLY;
|
|
||||||
else if (str.substr(0,7) == "numpad+")
|
|
||||||
return OpenArena::KEY_ADD;
|
|
||||||
else if (str.substr(0,7) == "numpad/")
|
|
||||||
return OpenArena::KEY_DIVIDE;
|
|
||||||
else if (str.substr(0,7) == "numpad-")
|
|
||||||
return OpenArena::KEY_SUBTRACT;
|
|
||||||
else if (str.substr(0,6) == "scroll")
|
|
||||||
return OpenArena::KEY_SCROLL;
|
|
||||||
else if (str.substr(0,7) == "numlock")
|
|
||||||
return OpenArena::KEY_NUMLOCK;
|
|
||||||
else if (str.substr(0,5) == "pause")
|
|
||||||
return OpenArena::KEY_PAUSE;
|
|
||||||
else if (str.substr(0,8) == "capslock")
|
|
||||||
return OpenArena::KEY_CAPITAL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*uncomment this to enable f1 as a mappable key
|
|
||||||
else if(str.substr(0,2) == "f1")
|
|
||||||
return OpenArena::KEY_F1;
|
|
||||||
*/
|
|
||||||
|
|
||||||
else if (str.substr(0,2) == "f2")
|
|
||||||
return OpenArena::KEY_F2;
|
|
||||||
else if (str.substr(0,2) == "f3")
|
|
||||||
return OpenArena::KEY_F3;
|
|
||||||
else if (str.substr(0,2) == "f4")
|
|
||||||
return OpenArena::KEY_F4;
|
|
||||||
else if (str.substr(0,2) == "f5")
|
|
||||||
return OpenArena::KEY_F5;
|
|
||||||
else if (str.substr(0,2) == "f6")
|
|
||||||
return OpenArena::KEY_F6;
|
|
||||||
else if (str.substr(0,2) == "f7")
|
|
||||||
return OpenArena::KEY_F7;
|
|
||||||
else if (str.substr(0,2) == "f8")
|
|
||||||
return OpenArena::KEY_F8;
|
|
||||||
else if (str.substr(0,2) == "f9")
|
|
||||||
return OpenArena::KEY_F9;
|
|
||||||
else if (str.substr(0,2) == "f10")
|
|
||||||
return OpenArena::KEY_F10;
|
|
||||||
else if (str.substr(0,2) == "f11")
|
|
||||||
return OpenArena::KEY_F11;
|
|
||||||
else if (str.substr(0,2) == "f12")
|
|
||||||
return OpenArena::KEY_F12;
|
|
||||||
//Add Game specific keys here and e-mail headhunter45@hotmail.com subject OpenArena keys so I can add them please
|
|
||||||
else if (str.substr(0,4) == "null")
|
|
||||||
return (uint8)NULL;
|
|
||||||
else
|
|
||||||
return (uint8)NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(str[0] == '~' || str[0] == '`')
|
|
||||||
return OpenArena::KEY_OEM_3;
|
|
||||||
else if (str[0] == '?' || str[0] == '/')
|
|
||||||
return OpenArena::KEY_OEM_2;
|
|
||||||
else if (str[0] == '.' || str[0] == '>')
|
|
||||||
return OpenArena::KEY_OEM_PERIOD;
|
|
||||||
else if (str[0] == '+' || str[0] == '=')
|
|
||||||
return OpenArena::KEY_OEM_PLUS;
|
|
||||||
else if (str[0] == ';' || str[0] == ':')
|
|
||||||
return OpenArena::KEY_OEM_1;
|
|
||||||
else if (str[0] == ',' || str[0] == '<')
|
|
||||||
return OpenArena::KEY_OEM_COMMA;
|
|
||||||
else if (str[0] == '-' || str[0] == '_')
|
|
||||||
return OpenArena::KEY_OEM_MINUS;
|
|
||||||
else if (str[0] == '[' || str[0] == '{')
|
|
||||||
return OpenArena::KEY_OEM_4;
|
|
||||||
else if (str[0] == ']' || str[0] == '}')
|
|
||||||
return OpenArena::KEY_OEM_6;
|
|
||||||
else if (str[0] == '\\' || str[0] == '|')
|
|
||||||
return OpenArena::KEY_OEM_5;
|
|
||||||
else if (str[0] == '\'' || str[0] == '"')
|
|
||||||
return OpenArena::KEY_OEM_7;
|
|
||||||
else if (isalpha(str[0]))
|
|
||||||
return toupper(str[0]) - 'A' + OpenArena::KEY_A;
|
|
||||||
else if(isdigit(str[0]))
|
|
||||||
return str[0] - '0' + OpenArena::KEY_0;
|
|
||||||
else
|
|
||||||
return OpenArena::KEY_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string Right(string str, uint32 len)
|
string Right(string str, uint32 len)
|
||||||
{
|
{
|
||||||
@@ -433,15 +279,24 @@ string word(string str, uint32 wordNum)
|
|||||||
{
|
{
|
||||||
if(wordNum < 1)
|
if(wordNum < 1)
|
||||||
{
|
{
|
||||||
|
while(isspace(str[start]))
|
||||||
|
++start;
|
||||||
|
|
||||||
while (!isspace(str[++length]) && length < maxLength);
|
while (!isspace(str[++length]) && length < maxLength);
|
||||||
|
|
||||||
|
if(length < maxLength || isspace(str[length])){
|
||||||
|
if(length >0)
|
||||||
|
{
|
||||||
|
length--;
|
||||||
|
}
|
||||||
|
}
|
||||||
return str.substr(start, length);
|
return str.substr(start, length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(isspace(str[start]))
|
while(isspace(str[start]))
|
||||||
++start;
|
++start;
|
||||||
|
|
||||||
for(uint32 i=0; i<wordNum; i++)
|
for(uint32 i=0; i<wordNum; i++)
|
||||||
{
|
{
|
||||||
while(start <maxLength && !isspace(str[start]))// && start <= maxLength)
|
while(start <maxLength && !isspace(str[start]))// && start <= maxLength)
|
||||||
|
|||||||
@@ -97,28 +97,6 @@ int Integer(string str);
|
|||||||
* Separate items with the '|' character.
|
* Separate items with the '|' character.
|
||||||
*/
|
*/
|
||||||
float Floating(string str);
|
float Floating(string str);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for KeyName here.
|
|
||||||
*
|
|
||||||
* \param str
|
|
||||||
* Description of parameter str.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for KeyName here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for KeyName here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
uint8 KeyName(string str);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
|||||||
10
src/tga.h
10
src/tga.h
@@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006 by Tom Hicks *
|
* Copyright (C) 2006 by Tom Hicks *
|
||||||
* tomhicks@cse.buffalo.edu *
|
* tomhicks@cse.buffalo.edu *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@@ -24,11 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma comment(lib, "OpenGL32.lib")
|
#include "mygl.h"
|
||||||
#ifdef WIN32
|
|
||||||
#include <windows.h> //I think this was only needed because gl.h uses it
|
|
||||||
#endif
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|||||||
185
src/window.cpp
185
src/window.cpp
@@ -27,7 +27,7 @@ void OpenArena::Window::SwapBuffers()
|
|||||||
glXSwapBuffers(display, window);
|
glXSwapBuffers(display, window);
|
||||||
}
|
}
|
||||||
#elif defined USE_AGL
|
#elif defined USE_AGL
|
||||||
aglSwapBuffers(aglContext);
|
aglSwapBuffers(_aglContext);
|
||||||
#elif defined USE_CGL
|
#elif defined USE_CGL
|
||||||
CGLFlushDrawable(cglContext);
|
CGLFlushDrawable(cglContext);
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
@@ -35,71 +35,6 @@ void OpenArena::Window::SwapBuffers()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenArena::Window::Close()
|
|
||||||
{
|
|
||||||
#if defined USE_GLX
|
|
||||||
if(_fullscreen)
|
|
||||||
{
|
|
||||||
#if defined HAVE_XF86VIDMODE
|
|
||||||
XF86VidModeSwitchToMode(display, screen, &vidMode);
|
|
||||||
XF86VidModeSetViewPort(display, screen, 0, 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hRC)
|
|
||||||
{
|
|
||||||
if(!glXMakeCurrent(display, None, NULL))
|
|
||||||
{
|
|
||||||
printf("Could not release drawing context.\n");
|
|
||||||
}
|
|
||||||
glXDestroyContext(display, hRC);
|
|
||||||
hRC = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
XCloseDisplay(display);
|
|
||||||
#elif defined USE_AGL
|
|
||||||
#error unimplemented method
|
|
||||||
#elif defined USE_CGL
|
|
||||||
#error unimplemented method
|
|
||||||
#elif defined USE_WGL
|
|
||||||
if(_fullscreen)
|
|
||||||
{
|
|
||||||
ChangeDisplaySettings(NULL, 0);
|
|
||||||
ShowCursor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(glContext)
|
|
||||||
{
|
|
||||||
if(!wglMakeCurrent(NULL, NULL))
|
|
||||||
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
|
||||||
|
|
||||||
if (!wglDeleteContext(glContext))
|
|
||||||
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
|
||||||
|
|
||||||
glContext=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deviceContext && !ReleaseDC(window, deviceContext))
|
|
||||||
{
|
|
||||||
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
|
||||||
deviceContext=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window && !DestroyWindow(window))
|
|
||||||
{
|
|
||||||
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
|
||||||
window=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UnregisterClass("OpenArena v0.1.0", instance))
|
|
||||||
{
|
|
||||||
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
|
||||||
instance=NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool OpenArena::Window::Open()
|
bool OpenArena::Window::Open()
|
||||||
{
|
{
|
||||||
#if defined USE_GLX
|
#if defined USE_GLX
|
||||||
@@ -210,7 +145,46 @@ bool OpenArena::Window::Open()
|
|||||||
_initializer->Initialize();
|
_initializer->Initialize();
|
||||||
return true;
|
return true;
|
||||||
#elif defined USE_AGL
|
#elif defined USE_AGL
|
||||||
|
OSStatus err = noErr;
|
||||||
|
SetRect(&_bounds, 0, 0, 640, 480);
|
||||||
|
err = CreateNewWindow(kDocumentWindowClass, kWindowStandardHandlerAttribute | kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute, &_bounds, &_window);
|
||||||
|
if(err != noErr)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RepositionWindow(_window, NULL, kWindowCascadeOnMainScreen);
|
||||||
|
|
||||||
|
AGLDevice* devices = NULL;
|
||||||
|
GLint deviceCount = 0;
|
||||||
|
GLint attributes[] = {AGL_ACCELERATED, AGL_NO_RECOVERY, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE};
|
||||||
|
AGLPixelFormat pixelFormat;
|
||||||
|
|
||||||
|
pixelFormat = aglChoosePixelFormat(devices,deviceCount,attributes);
|
||||||
|
_aglContext = aglCreateContext(pixelFormat, NULL);
|
||||||
|
if(!_aglContext)
|
||||||
|
{
|
||||||
|
exit (5);
|
||||||
|
}
|
||||||
|
|
||||||
|
aglDestroyPixelFormat(pixelFormat);
|
||||||
|
|
||||||
|
if(!aglSetCurrentContext(_aglContext))
|
||||||
|
{
|
||||||
|
exit(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!aglSetDrawable(_aglContext, GetWindowPort(_window)))
|
||||||
|
{
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
aglSwapBuffers(_aglContext);
|
||||||
|
ShowWindow(_window);
|
||||||
#elif defined USE_CGL
|
#elif defined USE_CGL
|
||||||
|
#error undefined method
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
unsigned int PixelFormat;
|
unsigned int PixelFormat;
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
@@ -339,6 +313,75 @@ bool OpenArena::Window::Open()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenArena::Window::Close()
|
||||||
|
{
|
||||||
|
#if defined USE_GLX
|
||||||
|
if(_fullscreen)
|
||||||
|
{
|
||||||
|
#if defined HAVE_XF86VIDMODE
|
||||||
|
XF86VidModeSwitchToMode(display, screen, &vidMode);
|
||||||
|
XF86VidModeSetViewPort(display, screen, 0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hRC)
|
||||||
|
{
|
||||||
|
if(!glXMakeCurrent(display, None, NULL))
|
||||||
|
{
|
||||||
|
printf("Could not release drawing context.\n");
|
||||||
|
}
|
||||||
|
glXDestroyContext(display, hRC);
|
||||||
|
hRC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
#elif defined USE_AGL
|
||||||
|
if(!_fullscreen)
|
||||||
|
{
|
||||||
|
aglSetCurrentContext(NULL);
|
||||||
|
aglDestroyContext(_aglContext);
|
||||||
|
_aglContext = NULL;
|
||||||
|
}
|
||||||
|
#elif defined USE_CGL
|
||||||
|
#error unimplemented method
|
||||||
|
#elif defined USE_WGL
|
||||||
|
if(_fullscreen)
|
||||||
|
{
|
||||||
|
ChangeDisplaySettings(NULL, 0);
|
||||||
|
ShowCursor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(glContext)
|
||||||
|
{
|
||||||
|
if(!wglMakeCurrent(NULL, NULL))
|
||||||
|
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||||
|
|
||||||
|
if (!wglDeleteContext(glContext))
|
||||||
|
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||||
|
|
||||||
|
glContext=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceContext && !ReleaseDC(window, deviceContext))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||||
|
deviceContext=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window && !DestroyWindow(window))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||||
|
window=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UnregisterClass("OpenArena v0.1.0", instance))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
|
||||||
|
instance=NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -423,11 +466,11 @@ OpenArena::Vec2i OpenArena::Window::GetMousePosition()
|
|||||||
{
|
{
|
||||||
return Vec2i(mouseX, mouseY);
|
return Vec2i(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
#elif USE_AGL
|
#elif defined USE_AGL
|
||||||
|
#warning unimplemented method
|
||||||
|
#elif defined USE_CGL
|
||||||
#error unimplemented method
|
#error unimplemented method
|
||||||
#elif USE_CGL
|
#elif defined USE_WGL
|
||||||
#error unimplemented method
|
|
||||||
#elif USE_WGL
|
|
||||||
POINT pos;
|
POINT pos;
|
||||||
GetCursorPos(&pos);
|
GetCursorPos(&pos);
|
||||||
return Vec2i(pos.x, pos.y);
|
return Vec2i(pos.x, pos.y);
|
||||||
@@ -439,7 +482,7 @@ void OpenArena::Window::SetMousePosition(Vec2i pos)
|
|||||||
#if defined USE_GLX
|
#if defined USE_GLX
|
||||||
XWarpPointer(display, None, window, 0, 0, 0, 0, pos.x, pos.y);
|
XWarpPointer(display, None, window, 0, 0, 0, 0, pos.x, pos.y);
|
||||||
#elif defined USE_AGL
|
#elif defined USE_AGL
|
||||||
#error unimplemented method
|
#warning unimplemented method
|
||||||
#elif defined USE_CGL
|
#elif defined USE_CGL
|
||||||
#error unimplemented method
|
#error unimplemented method
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
|
|||||||
338
src/window.h
338
src/window.h
@@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006 by Tom Hicks *
|
* Copyright (C) 2006 by Tom Hicks *
|
||||||
* tomhicks@cse.buffalo.edu *
|
* tomhicks@cse.buffalo.edu *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
#elif defined USE_AGL
|
#elif defined USE_AGL
|
||||||
#include <AGL/agl.h>
|
#include <AGL/agl.h>
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
#elif defined USE_CGL
|
#elif defined USE_CGL
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
@@ -54,329 +55,32 @@
|
|||||||
|
|
||||||
namespace OpenArena
|
namespace OpenArena
|
||||||
{
|
{
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Window here.
|
|
||||||
*
|
|
||||||
* Write detailed description for Window here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Window here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
class Window: public Screen
|
class Window: public Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Resizer here.
|
|
||||||
*
|
|
||||||
* Write detailed description for Resizer here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Resizer here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
class Resizer
|
class Resizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Resize here.
|
|
||||||
*
|
|
||||||
* \param width
|
|
||||||
* Description of parameter width.
|
|
||||||
*
|
|
||||||
* \param height
|
|
||||||
* Description of parameter height.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Resize here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Resize here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Resize(GLsizei width, GLsizei height);
|
void Resize(GLsizei width, GLsizei height);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Initializer here.
|
|
||||||
*
|
|
||||||
* Write detailed description for Initializer here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Initializer here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
class Initializer
|
class Initializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Initialize here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Initialize here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Initialize here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
int Initialize();
|
int Initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Window here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Window here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Window here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
Window();
|
Window();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for ~Window here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for ~Window here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for ~Window here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
~Window();
|
~Window();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Close here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Close here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Close here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Close();
|
void Close();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Open here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Open here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Open here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
bool Open();
|
bool Open();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Open here.
|
|
||||||
*
|
|
||||||
* \param title
|
|
||||||
* Description of parameter title.
|
|
||||||
*
|
|
||||||
* \param width
|
|
||||||
* Description of parameter width.
|
|
||||||
*
|
|
||||||
* \param height
|
|
||||||
* Description of parameter height.
|
|
||||||
*
|
|
||||||
* \param bits
|
|
||||||
* Description of parameter bits.
|
|
||||||
*
|
|
||||||
* \param fullscreenflag
|
|
||||||
* Description of parameter fullscreenflag.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Open here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Open here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
bool Open(string title, int width, int height, int bits, bool fullscreenflag); //make that string a const char* after this works
|
bool Open(string title, int width, int height, int bits, bool fullscreenflag); //make that string a const char* after this works
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SetInitializer here.
|
|
||||||
*
|
|
||||||
* \param initializer
|
|
||||||
* Description of parameter initializer.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SetInitializer here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SetInitializer here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SetInitializer(Initializer* initializer);
|
void SetInitializer(Initializer* initializer);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SetResizer here.
|
|
||||||
*
|
|
||||||
* \param resizer
|
|
||||||
* Description of parameter resizer.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SetResizer here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SetResizer here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SetResizer here.
|
|
||||||
*
|
|
||||||
* \param resizer
|
|
||||||
* Description of parameter resizer.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SetResizer here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SetResizer here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SetResizer(Resizer* resizer);
|
void SetResizer(Resizer* resizer);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SwapBuffers here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SwapBuffers here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SwapBuffers here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SwapBuffers();
|
void SwapBuffers();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for Resize here.
|
|
||||||
*
|
|
||||||
* \param width
|
|
||||||
* Description of parameter width.
|
|
||||||
*
|
|
||||||
* \param height
|
|
||||||
* Description of parameter height.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for Resize here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for Resize here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void Resize(GLsizei width, GLsizei height);
|
void Resize(GLsizei width, GLsizei height);
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for GetMousePosition here.
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for GetMousePosition here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for GetMousePosition here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
Vec2i GetMousePosition();
|
Vec2i GetMousePosition();
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for SetMousePosition here.
|
|
||||||
*
|
|
||||||
* \param pos
|
|
||||||
* Description of parameter pos.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for SetMousePosition here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for SetMousePosition here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
void SetMousePosition(Vec2i pos);
|
void SetMousePosition(Vec2i pos);
|
||||||
|
|
||||||
#ifdef USE_GLX
|
#ifdef USE_GLX
|
||||||
@@ -395,7 +99,11 @@ namespace OpenArena
|
|||||||
XF86VidModeModeInfo vidMode;
|
XF86VidModeModeInfo vidMode;
|
||||||
#endif
|
#endif
|
||||||
int x, y;
|
int x, y;
|
||||||
Display* display;
|
Display* display;
|
||||||
|
#elif defined USE_AGL
|
||||||
|
AGLContext _aglContext;
|
||||||
|
WindowRef _window;
|
||||||
|
Rect _bounds;
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
HGLRC glContext;
|
HGLRC glContext;
|
||||||
HWND window;
|
HWND window;
|
||||||
@@ -411,36 +119,6 @@ namespace OpenArena
|
|||||||
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None};
|
||||||
#elif defined USE_WGL
|
#elif defined USE_WGL
|
||||||
/*!
|
|
||||||
* \brief
|
|
||||||
* Write brief comment for WndProc here.
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \param
|
|
||||||
* Description of parameter .
|
|
||||||
*
|
|
||||||
* \returns
|
|
||||||
* Write description of return value here.
|
|
||||||
*
|
|
||||||
* \throws <exception class>
|
|
||||||
* Description of criteria for throwing this exception.
|
|
||||||
*
|
|
||||||
* Write detailed description for WndProc here.
|
|
||||||
*
|
|
||||||
* \remarks
|
|
||||||
* Write remarks for WndProc here.
|
|
||||||
*
|
|
||||||
* \see
|
|
||||||
* Separate items with the '|' character.
|
|
||||||
*/
|
|
||||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,6 @@
|
|||||||
|
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
|
|
||||||
static OpenArena::Level level;
|
//static OpenArena::Level level;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
107
src/x11.cpp
107
src/x11.cpp
@@ -47,26 +47,13 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "x11.h"
|
#include "x11.h"
|
||||||
|
#if defined USE_GLX
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void InitControls(OpenArena::EventManager* em)
|
int InitGL(OpenArena::Level* level)
|
||||||
{
|
{
|
||||||
if (!level.LoadConfig("my.cfg"))
|
level->LoadGLTextures();
|
||||||
{
|
|
||||||
level.LoadConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitControls()
|
|
||||||
{
|
|
||||||
if (!level.LoadConfig("my.cfg"))
|
|
||||||
level.LoadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
int InitGL(GLvoid)
|
|
||||||
{
|
|
||||||
level.LoadGLTextures();
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
@@ -78,11 +65,11 @@ int InitGL(GLvoid)
|
|||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||||
|
|
||||||
/*lighting disabled temporarily
|
/*lighting disabled temporarily
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, level.LightAmbient);
|
glLightfv(GL_LIGHT1, GL_AMBIENT, level->LightAmbient);
|
||||||
for(index=0; index<level.numLights; index++)
|
for(index=0; index<level->numLights; index++)
|
||||||
{
|
{
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, level.light[index].color);
|
glLightfv(GL_LIGHT1, GL_DIFFUSE, level->light[index].color);
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION, level.light[index].coords);
|
glLightfv(GL_LIGHT1, GL_POSITION, level->light[index].coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_LIGHT1);
|
glEnable(GL_LIGHT1);
|
||||||
@@ -93,7 +80,7 @@ int InitGL(GLvoid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This should probably be moved into oa_input
|
//This should probably be moved into oa_input
|
||||||
unsigned char TranslateKey(int keyCode)
|
OpenArena::Keys TranslateKey(int keyCode)
|
||||||
{
|
{
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
@@ -335,46 +322,23 @@ unsigned char TranslateKey(int keyCode)
|
|||||||
case XK_slash:
|
case XK_slash:
|
||||||
return OpenArena::KEY_OEM_2;
|
return OpenArena::KEY_OEM_2;
|
||||||
case XK_Alt_L:
|
case XK_Alt_L:
|
||||||
return OpenArena::KEY_UNKNOWN;
|
return OpenArena::KEY_ALT_L;
|
||||||
case XK_Alt_R:
|
case XK_Alt_R:
|
||||||
return OpenArena::KEY_UNKNOWN;
|
return OpenArena::KEY_ALT_L;
|
||||||
|
case XK_equal:
|
||||||
/*These keys definately still need to be accounted for
|
return OpenArena::KEY_OEM_PLUS;
|
||||||
` 96
|
case XK_Mode_switch:
|
||||||
pause 65299
|
return OpenArena::KEY_OPTION;
|
||||||
win 65515
|
case XK_Meta_L:
|
||||||
apps 65383
|
return OpenArena::KEY_COMMAND;
|
||||||
- 45
|
case 16777219:
|
||||||
= 61
|
return OpenArena::KEY_ENTER;
|
||||||
[ 91
|
|
||||||
] 93
|
|
||||||
\ 92
|
|
||||||
; 59
|
|
||||||
' 39
|
|
||||||
' 47
|
|
||||||
left alt 65513
|
|
||||||
right alt 65514
|
|
||||||
|
|
||||||
#define KEY_LBUTTON 1
|
|
||||||
#define KEY_RBUTTON 2
|
|
||||||
#define KEY_MBUTTON 3
|
|
||||||
#define KEY_LWIN 21
|
|
||||||
#define KEY_RWIN 22
|
|
||||||
#define KEY_APPS 23
|
|
||||||
#define KEY_OEM_1 53
|
|
||||||
#define KEY_OEM_2 54
|
|
||||||
#define KEY_OEM_3 55
|
|
||||||
#define KEY_OEM_4 56
|
|
||||||
#define KEY_OEM_5 57
|
|
||||||
#define KEY_OEM_6 58
|
|
||||||
#define KEY_OEM_7 59
|
|
||||||
*/
|
|
||||||
default:
|
default:
|
||||||
return OpenArena::KEY_UNKNOWN;
|
return OpenArena::KEY_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char TranslateButton(int keyCode)
|
OpenArena::Keys TranslateButton(int keyCode)
|
||||||
{
|
{
|
||||||
switch(keyCode)
|
switch(keyCode)
|
||||||
{
|
{
|
||||||
@@ -391,44 +355,36 @@ unsigned char TranslateButton(int keyCode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleConsoleKeyPress(OpenArena::Keys key)
|
void HandleConsoleKeyPress(OpenArena::Keys key, OpenArena::Level* level)
|
||||||
{
|
{
|
||||||
//See if we need to hide the console
|
if(level->defaultPlayer[0].controls.IsBound(key, OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE))
|
||||||
level.defaultPlayer[0].controls.toggleConsole.FirstPosition();
|
|
||||||
if(key == level.defaultPlayer[0].controls.toggleConsole.Retrieve())
|
|
||||||
{
|
{
|
||||||
level.showConsole = false;
|
level->showConsole = false;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while(level.defaultPlayer[0].controls.toggleConsole.NextPosition() && level.showConsole)
|
|
||||||
{
|
|
||||||
if(level.defaultPlayer[0].controls.toggleConsole.Retrieve() == key)
|
|
||||||
{
|
|
||||||
level.showConsole = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case OpenArena::KEY_SHIFT:
|
case OpenArena::KEY_SHIFT:
|
||||||
keys[OpenArena::KEY_SHIFT] = true;
|
keys[OpenArena::KEY_SHIFT] = true;
|
||||||
break;
|
break;
|
||||||
case OpenArena::KEY_RETURN:
|
case OpenArena::KEY_RETURN:
|
||||||
level.UpdateConsole('\n');
|
level->UpdateConsole('\n');
|
||||||
break;
|
break;
|
||||||
case OpenArena::KEY_SPACE:
|
case OpenArena::KEY_SPACE:
|
||||||
printf("hello");
|
printf("hello");
|
||||||
level.UpdateConsole(' ');
|
level->UpdateConsole(' ');
|
||||||
break;
|
break;
|
||||||
case OpenArena::KEY_BACK:
|
case OpenArena::KEY_BACK:
|
||||||
level.UpdateConsole(OpenArena::KEY_BACK);
|
level->UpdateConsole(OpenArena::KEY_BACK);
|
||||||
|
break;
|
||||||
|
case OpenArena::KEY_ESCAPE:
|
||||||
|
level->showConsole = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
char ascii = OpenArena::KeyToASCII(key, keys[OpenArena::KEY_SHIFT]);
|
char ascii = OpenArena::KeyToASCII(key, keys[OpenArena::KEY_SHIFT]);
|
||||||
if(ascii != '\0')
|
if(ascii != '\0')
|
||||||
{
|
{
|
||||||
level.UpdateConsole(ascii);
|
level->UpdateConsole(ascii);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,5 +403,6 @@ void ResizeGLScene(GLsizei width, GLsizei height)
|
|||||||
|
|
||||||
void RT()
|
void RT()
|
||||||
{
|
{
|
||||||
g_Screen.SwapBuffers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* USE_GLX */
|
||||||
|
|||||||
30
src/x11.h
30
src/x11.h
@@ -19,28 +19,22 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef __x11_h__
|
#ifndef __x11_h__
|
||||||
#define __x11_h__
|
#define __x11_h__
|
||||||
|
#if defined HAVE_CONFIG_H
|
||||||
/**
|
#include "config.h"
|
||||||
* @file x11.h
|
#endif
|
||||||
* @breif Specification of an X11 Event loop
|
|
||||||
* This file along with x11.cpp implement an X11 Event loop to
|
|
||||||
* process and dispatch events to the specified EventManager.
|
|
||||||
*
|
|
||||||
* @see x11.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
#if defined USE_GLX
|
||||||
#include "mygl.h"
|
#include "mygl.h"
|
||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
|
#include "level.h"
|
||||||
|
|
||||||
int DrawGLScene();
|
int DrawGLScene();
|
||||||
unsigned char TranslateButton(int keyCode);
|
OpenArena::Keys TranslateButton(int keyCode);
|
||||||
unsigned char TranslateKey(int keyCode);
|
OpenArena::Keys TranslateKey(int keyCode);
|
||||||
void ResizeGLScene(GLsizei width, GLsizei height);
|
void ResizeGLScene(GLsizei width, GLsizei height);
|
||||||
void HandleConsoleKeyPress(OpenArena::Keys key);
|
void HandleConsoleKeyPress(OpenArena::Keys key);
|
||||||
int DrawGLScene();
|
int DrawGLScene(OpenArena::Level* level);
|
||||||
void InitControls();
|
int InitGL(OpenArena::Level* level);
|
||||||
void InitControls(OpenArena::EventManager* em);
|
void HandleConsoleKeyPress(OpenArena::Keys key, OpenArena::Level* level);
|
||||||
int InitGL(GLvoid);
|
#endif /* USE_GLX */
|
||||||
void RT();
|
#endif /* __x11_h__ */
|
||||||
|
|
||||||
#endif /*__x11_h__*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user