forked from 0ad/0ad
Some range-based for loops and some style cleanup.
This was SVN commit r16888.
This commit is contained in:
parent
b4d517c261
commit
a07add11c6
@ -44,11 +44,10 @@ CObjectEntry::CObjectEntry(CObjectBase* base, CSimulation2& simulation) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename S> static void delete_pair_2nd(std::pair<T,S> v) { delete v.second; }
|
|
||||||
|
|
||||||
CObjectEntry::~CObjectEntry()
|
CObjectEntry::~CObjectEntry()
|
||||||
{
|
{
|
||||||
std::for_each(m_Animations.begin(), m_Animations.end(), delete_pair_2nd<CStr, CSkeletonAnim*>);
|
for (const std::pair<CStr, CSkeletonAnim*>& anim : m_Animations)
|
||||||
|
delete anim.second;
|
||||||
|
|
||||||
delete m_Model;
|
delete m_Model;
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,14 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
#include "CLogger.h"
|
#include "CLogger.h"
|
||||||
#include "CConsole.h"
|
|
||||||
#include "graphics/FontMetrics.h"
|
#include "graphics/FontMetrics.h"
|
||||||
#include "graphics/ShaderManager.h"
|
#include "graphics/ShaderManager.h"
|
||||||
#include "graphics/TextRenderer.h"
|
#include "graphics/TextRenderer.h"
|
||||||
#include "lib/ogl.h"
|
#include "lib/ogl.h"
|
||||||
#include "lib/timer.h"
|
#include "lib/timer.h"
|
||||||
#include "lib/utf8.h"
|
#include "lib/utf8.h"
|
||||||
|
#include "ps/CConsole.h"
|
||||||
#include "ps/Profile.h"
|
#include "ps/Profile.h"
|
||||||
#include "renderer/Renderer.h"
|
#include "renderer/Renderer.h"
|
||||||
|
|
||||||
@ -223,15 +224,15 @@ void CLogger::Render()
|
|||||||
// and attempt to lock the mutex recursively which is forbidden)
|
// and attempt to lock the mutex recursively which is forbidden)
|
||||||
CScopeLock lock(m_Mutex);
|
CScopeLock lock(m_Mutex);
|
||||||
|
|
||||||
for (std::deque<RenderedMessage>::iterator it = m_RenderMessages.begin(); it != m_RenderMessages.end(); ++it)
|
for (const RenderedMessage& msg : m_RenderMessages)
|
||||||
{
|
{
|
||||||
const char* type;
|
const char* type;
|
||||||
if (it->method == Normal)
|
if (msg.method == Normal)
|
||||||
{
|
{
|
||||||
type = "info";
|
type = "info";
|
||||||
textRenderer.Color(0.0f, 0.8f, 0.0f);
|
textRenderer.Color(0.0f, 0.8f, 0.0f);
|
||||||
}
|
}
|
||||||
else if (it->method == Warning)
|
else if (msg.method == Warning)
|
||||||
{
|
{
|
||||||
type = "warning";
|
type = "warning";
|
||||||
textRenderer.Color(1.0f, 1.0f, 0.0f);
|
textRenderer.Color(1.0f, 1.0f, 0.0f);
|
||||||
@ -244,10 +245,10 @@ void CLogger::Render()
|
|||||||
|
|
||||||
CMatrix3D savedTransform = textRenderer.GetTransform();
|
CMatrix3D savedTransform = textRenderer.GetTransform();
|
||||||
|
|
||||||
textRenderer.PrintfAdvance(L"[%8.3f] %hs: ", it->time, type);
|
textRenderer.PrintfAdvance(L"[%8.3f] %hs: ", msg.time, type);
|
||||||
// Display the actual message in white so it's more readable
|
// Display the actual message in white so it's more readable
|
||||||
textRenderer.Color(1.0f, 1.0f, 1.0f);
|
textRenderer.Color(1.0f, 1.0f, 1.0f);
|
||||||
textRenderer.Put(0.0f, 0.0f, it->message.c_str());
|
textRenderer.Put(0.0f, 0.0f, msg.message.c_str());
|
||||||
|
|
||||||
textRenderer.SetTransform(savedTransform);
|
textRenderer.SetTransform(savedTransform);
|
||||||
|
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
#include "ConfigDB.h"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "CLogger.h"
|
|
||||||
#include "ConfigDB.h"
|
|
||||||
#include "Filesystem.h"
|
|
||||||
#include "ThreadUtil.h"
|
|
||||||
#include "lib/allocators/shared_ptr.h"
|
#include "lib/allocators/shared_ptr.h"
|
||||||
|
#include "ps/CLogger.h"
|
||||||
|
#include "ps/Filesystem.h"
|
||||||
|
#include "ps/ThreadUtil.h"
|
||||||
|
|
||||||
typedef std::map<CStr, CConfigValueSet> TConfigMap;
|
typedef std::map<CStr, CConfigValueSet> TConfigMap;
|
||||||
TConfigMap CConfigDB::m_Map[CFG_LAST];
|
TConfigMap CConfigDB::m_Map[CFG_LAST];
|
||||||
@ -96,7 +97,7 @@ std::string EscapeString(const CStr& str)
|
|||||||
Get(it->second[0], value);\
|
Get(it->second[0], value);\
|
||||||
return;\
|
return;\
|
||||||
}\
|
}\
|
||||||
for (int search_ns = ns; search_ns >= 0; search_ns--)\
|
for (int search_ns = ns; search_ns >= 0; --search_ns)\
|
||||||
{\
|
{\
|
||||||
it = m_Map[search_ns].find(name);\
|
it = m_Map[search_ns].find(name);\
|
||||||
if (it != m_Map[search_ns].end())\
|
if (it != m_Map[search_ns].end())\
|
||||||
@ -113,7 +114,7 @@ GETVAL(double)
|
|||||||
GETVAL(std::string)
|
GETVAL(std::string)
|
||||||
#undef GETVAL
|
#undef GETVAL
|
||||||
|
|
||||||
void CConfigDB::GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet& values)
|
void CConfigDB::GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet& values) const
|
||||||
{
|
{
|
||||||
CHECK_NS(;);
|
CHECK_NS(;);
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ void CConfigDB::GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int search_ns = ns; search_ns >= 0; search_ns--)
|
for (int search_ns = ns; search_ns >= 0; --search_ns)
|
||||||
{
|
{
|
||||||
it = m_Map[search_ns].find(name);
|
it = m_Map[search_ns].find(name);
|
||||||
if (it != m_Map[search_ns].end())
|
if (it != m_Map[search_ns].end())
|
||||||
@ -136,7 +137,7 @@ void CConfigDB::GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EConfigNamespace CConfigDB::GetValueNamespace(EConfigNamespace ns, const CStr& name)
|
EConfigNamespace CConfigDB::GetValueNamespace(EConfigNamespace ns, const CStr& name) const
|
||||||
{
|
{
|
||||||
CHECK_NS(CFG_LAST);
|
CHECK_NS(CFG_LAST);
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ EConfigNamespace CConfigDB::GetValueNamespace(EConfigNamespace ns, const CStr& n
|
|||||||
if (it != m_Map[CFG_COMMAND].end())
|
if (it != m_Map[CFG_COMMAND].end())
|
||||||
return CFG_COMMAND;
|
return CFG_COMMAND;
|
||||||
|
|
||||||
for (int search_ns = ns; search_ns >= 0; search_ns--)
|
for (int search_ns = ns; search_ns >= 0; --search_ns)
|
||||||
{
|
{
|
||||||
it = m_Map[search_ns].find(name);
|
it = m_Map[search_ns].find(name);
|
||||||
if (it != m_Map[search_ns].end())
|
if (it != m_Map[search_ns].end())
|
||||||
@ -155,7 +156,7 @@ EConfigNamespace CConfigDB::GetValueNamespace(EConfigNamespace ns, const CStr& n
|
|||||||
return CFG_LAST;
|
return CFG_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<CStr, CConfigValueSet> CConfigDB::GetValuesWithPrefix(EConfigNamespace ns, const CStr& prefix)
|
std::map<CStr, CConfigValueSet> CConfigDB::GetValuesWithPrefix(EConfigNamespace ns, const CStr& prefix) const
|
||||||
{
|
{
|
||||||
CScopeLock s(&cfgdb_mutex);
|
CScopeLock s(&cfgdb_mutex);
|
||||||
std::map<CStr, CConfigValueSet> ret;
|
std::map<CStr, CConfigValueSet> ret;
|
||||||
@ -164,20 +165,14 @@ std::map<CStr, CConfigValueSet> CConfigDB::GetValuesWithPrefix(EConfigNamespace
|
|||||||
|
|
||||||
// Loop upwards so that values in later namespaces can override
|
// Loop upwards so that values in later namespaces can override
|
||||||
// values in earlier namespaces
|
// values in earlier namespaces
|
||||||
for (int search_ns = 0; search_ns <= ns; search_ns++)
|
for (int search_ns = 0; search_ns <= ns; ++search_ns)
|
||||||
{
|
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[search_ns])
|
||||||
for (TConfigMap::iterator it = m_Map[search_ns].begin(); it != m_Map[search_ns].end(); ++it)
|
if (boost::algorithm::starts_with(p.first, prefix))
|
||||||
{
|
ret[p.first] = p.second;
|
||||||
if (boost::algorithm::starts_with(it->first, prefix))
|
|
||||||
ret[it->first] = it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TConfigMap::iterator it = m_Map[CFG_COMMAND].begin(); it != m_Map[CFG_COMMAND].end(); ++it)
|
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[CFG_COMMAND])
|
||||||
{
|
if (boost::algorithm::starts_with(p.first, prefix))
|
||||||
if (boost::algorithm::starts_with(it->first, prefix))
|
ret[p.first] = p.second;
|
||||||
ret[it->first] = it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -365,7 +360,7 @@ bool CConfigDB::Reload(EConfigNamespace ns)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConfigDB::WriteFile(EConfigNamespace ns)
|
bool CConfigDB::WriteFile(EConfigNamespace ns) const
|
||||||
{
|
{
|
||||||
CHECK_NS(false);
|
CHECK_NS(false);
|
||||||
|
|
||||||
@ -373,7 +368,7 @@ bool CConfigDB::WriteFile(EConfigNamespace ns)
|
|||||||
return WriteFile(ns, m_ConfigFile[ns]);
|
return WriteFile(ns, m_ConfigFile[ns]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path)
|
bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path) const
|
||||||
{
|
{
|
||||||
CHECK_NS(false);
|
CHECK_NS(false);
|
||||||
|
|
||||||
@ -381,14 +376,13 @@ bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path)
|
|||||||
shared_ptr<u8> buf;
|
shared_ptr<u8> buf;
|
||||||
AllocateAligned(buf, 1*MiB, maxSectorSize);
|
AllocateAligned(buf, 1*MiB, maxSectorSize);
|
||||||
char* pos = (char*)buf.get();
|
char* pos = (char*)buf.get();
|
||||||
TConfigMap &map = m_Map[ns];
|
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[ns])
|
||||||
for (TConfigMap::const_iterator it = map.begin(); it != map.end(); ++it)
|
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
pos += sprintf(pos, "%s = ", it->first.c_str());
|
pos += sprintf(pos, "%s = ", p.first.c_str());
|
||||||
for (i = 0; i < it->second.size() - 1; ++i)
|
for (i = 0; i < p.second.size() - 1; ++i)
|
||||||
pos += sprintf(pos, "\"%s\", ", EscapeString(it->second[i]).c_str());
|
pos += sprintf(pos, "\"%s\", ", EscapeString(p.second[i]).c_str());
|
||||||
pos += sprintf(pos, "\"%s\"\n", EscapeString(it->second[i]).c_str());
|
pos += sprintf(pos, "\"%s\"\n", EscapeString(p.second[i]).c_str());
|
||||||
}
|
}
|
||||||
const size_t len = pos - (char*)buf.get();
|
const size_t len = pos - (char*)buf.get();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2015 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -27,10 +27,9 @@
|
|||||||
#ifndef INCLUDED_CONFIGDB
|
#ifndef INCLUDED_CONFIGDB
|
||||||
#define INCLUDED_CONFIGDB
|
#define INCLUDED_CONFIGDB
|
||||||
|
|
||||||
#include "CStr.h"
|
|
||||||
#include "Singleton.h"
|
|
||||||
|
|
||||||
#include "lib/file/vfs/vfs_path.h"
|
#include "lib/file/vfs/vfs_path.h"
|
||||||
|
#include "ps/CStr.h"
|
||||||
|
#include "ps/Singleton.h"
|
||||||
|
|
||||||
// Namespace priorities: User supersedes mod supersedes system.
|
// Namespace priorities: User supersedes mod supersedes system.
|
||||||
// Command-line arguments override everything.
|
// Command-line arguments override everything.
|
||||||
@ -77,20 +76,20 @@ public:
|
|||||||
* will search CFG_COMMAND first, and then all namespaces from the specified
|
* will search CFG_COMMAND first, and then all namespaces from the specified
|
||||||
* namespace down.
|
* namespace down.
|
||||||
*/
|
*/
|
||||||
void GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet& values);
|
void GetValues(EConfigNamespace ns, const CStr& name, CConfigValueSet& values) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the namespace that the value returned by GetValues was defined in,
|
* Returns the namespace that the value returned by GetValues was defined in,
|
||||||
* or CFG_LAST if it wasn't defined at all.
|
* or CFG_LAST if it wasn't defined at all.
|
||||||
*/
|
*/
|
||||||
EConfigNamespace GetValueNamespace(EConfigNamespace ns, const CStr& name);
|
EConfigNamespace GetValueNamespace(EConfigNamespace ns, const CStr& name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a map of values corresponding to settings whose names begin
|
* Retrieve a map of values corresponding to settings whose names begin
|
||||||
* with the given prefix;
|
* with the given prefix;
|
||||||
* will search all namespaces from default up to the specified namespace.
|
* will search all namespaces from default up to the specified namespace.
|
||||||
*/
|
*/
|
||||||
std::map<CStr, CConfigValueSet> GetValuesWithPrefix(EConfigNamespace ns, const CStr& prefix);
|
std::map<CStr, CConfigValueSet> GetValuesWithPrefix(EConfigNamespace ns, const CStr& prefix) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a config value in the specified namespace. If the config variable
|
* Save a config value in the specified namespace. If the config variable
|
||||||
@ -125,7 +124,7 @@ public:
|
|||||||
* true: if the config namespace was successfully written to the file
|
* true: if the config namespace was successfully written to the file
|
||||||
* false: if an error occurred
|
* false: if an error occurred
|
||||||
*/
|
*/
|
||||||
bool WriteFile(EConfigNamespace ns, const VfsPath& path);
|
bool WriteFile(EConfigNamespace ns, const VfsPath& path) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the current state of the specified config namespace to the file
|
* Write the current state of the specified config namespace to the file
|
||||||
@ -135,7 +134,7 @@ public:
|
|||||||
* true: if the config namespace was successfully written to the file
|
* true: if the config namespace was successfully written to the file
|
||||||
* false: if an error occurred
|
* false: if an error occurred
|
||||||
*/
|
*/
|
||||||
bool WriteFile(EConfigNamespace ns);
|
bool WriteFile(EConfigNamespace ns) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -144,4 +143,4 @@ public:
|
|||||||
#define CFG_GET_VAL(name, destination)\
|
#define CFG_GET_VAL(name, destination)\
|
||||||
g_ConfigDB.GetValue(CFG_USER, name, destination)
|
g_ConfigDB.GetValue(CFG_USER, name, destination)
|
||||||
|
|
||||||
#endif
|
#endif // INCLUDED_CONFIGDB
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014 Wildfire Games.
|
/* Copyright (C) 2015 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -21,12 +21,12 @@
|
|||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
|
|
||||||
#include "lib/input.h"
|
#include "lib/input.h"
|
||||||
#include "ConfigDB.h"
|
#include "ps/CConsole.h"
|
||||||
#include "CLogger.h"
|
#include "ps/CLogger.h"
|
||||||
#include "CConsole.h"
|
#include "ps/CStr.h"
|
||||||
#include "CStr.h"
|
#include "ps/ConfigDB.h"
|
||||||
#include "ps/Globals.h"
|
#include "ps/Globals.h"
|
||||||
#include "KeyName.h"
|
#include "ps/KeyName.h"
|
||||||
|
|
||||||
static bool unified[UNIFIED_LAST - UNIFIED_SHIFT];
|
static bool unified[UNIFIED_LAST - UNIFIED_SHIFT];
|
||||||
|
|
||||||
@ -64,13 +64,11 @@ std::map<std::string, bool> g_HotkeyStatus;
|
|||||||
// all key combinations that trigger it.
|
// all key combinations that trigger it.
|
||||||
static void LoadConfigBindings()
|
static void LoadConfigBindings()
|
||||||
{
|
{
|
||||||
std::map<CStr, CConfigValueSet> bindings = g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey.");
|
for (const std::pair<CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
|
||||||
for (std::map<CStr, CConfigValueSet>::iterator bindingsIt = bindings.begin(); bindingsIt != bindings.end(); ++bindingsIt)
|
|
||||||
{
|
{
|
||||||
std::string hotkeyName = bindingsIt->first.substr(7); // strip the "hotkey." prefix
|
std::string hotkeyName = configPair.first.substr(7); // strip the "hotkey." prefix
|
||||||
for (CConfigValueSet::iterator it = bindingsIt->second.begin(); it != bindingsIt->second.end(); ++it)
|
for (const CStr& hotkey : configPair.second)
|
||||||
{
|
{
|
||||||
const CStr& hotkey = *it;
|
|
||||||
std::vector<SKey> keyCombination;
|
std::vector<SKey> keyCombination;
|
||||||
|
|
||||||
// Iterate through multiple-key bindings (e.g. Ctrl+I)
|
// Iterate through multiple-key bindings (e.g. Ctrl+I)
|
||||||
@ -118,25 +116,21 @@ void LoadHotkeys()
|
|||||||
// Set up the state of the hotkeys given no key is down.
|
// Set up the state of the hotkeys given no key is down.
|
||||||
// i.e. find those hotkeys triggered by all negations.
|
// i.e. find those hotkeys triggered by all negations.
|
||||||
|
|
||||||
for( std::map<int, KeyMapping>::iterator mapIt = g_HotkeyMap.begin(); mapIt != g_HotkeyMap.end(); ++mapIt )
|
for (const std::pair<int, KeyMapping>& p : g_HotkeyMap)
|
||||||
{
|
for (const SHotkeyMapping& hotkey : p.second)
|
||||||
KeyMapping& hotkeyMap = mapIt->second;
|
|
||||||
|
|
||||||
for( std::vector<SHotkeyMapping>::iterator it = hotkeyMap.begin(); it != hotkeyMap.end(); ++it )
|
|
||||||
{
|
{
|
||||||
if( !it->negated )
|
if (!hotkey.negated)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool allNegated = true;
|
bool allNegated = true;
|
||||||
|
|
||||||
for( std::vector<SKey>::iterator j = it->requires.begin(); j != it->requires.end(); ++j )
|
for (const SKey& k : hotkey.requires)
|
||||||
if( !j->negated )
|
if (!k.negated)
|
||||||
allNegated = false;
|
allNegated = false;
|
||||||
|
|
||||||
if( allNegated )
|
if (allNegated)
|
||||||
g_HotkeyStatus[it->name] = true;
|
g_HotkeyStatus[hotkey.name] = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnloadHotkeys()
|
void UnloadHotkeys()
|
||||||
@ -160,11 +154,11 @@ bool isNegated(const SKey& key)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InReaction HotkeyInputHandler( const SDL_Event_* ev )
|
InReaction HotkeyInputHandler(const SDL_Event_* ev)
|
||||||
{
|
{
|
||||||
int keycode = 0;
|
int keycode = 0;
|
||||||
|
|
||||||
switch( ev->ev.type )
|
switch(ev->ev.type)
|
||||||
{
|
{
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
@ -232,46 +226,46 @@ InReaction HotkeyInputHandler( const SDL_Event_* ev )
|
|||||||
// Just send them to this handler; don't let the imaginary event codes leak back to real SDL.
|
// Just send them to this handler; don't let the imaginary event codes leak back to real SDL.
|
||||||
|
|
||||||
SDL_Event_ phantom;
|
SDL_Event_ phantom;
|
||||||
phantom.ev.type = ( ( ev->ev.type == SDL_KEYDOWN ) || ( ev->ev.type == SDL_MOUSEBUTTONDOWN ) ) ? SDL_KEYDOWN : SDL_KEYUP;
|
phantom.ev.type = ((ev->ev.type == SDL_KEYDOWN) || (ev->ev.type == SDL_MOUSEBUTTONDOWN)) ? SDL_KEYDOWN : SDL_KEYUP;
|
||||||
if( ( keycode == SDLK_LSHIFT ) || ( keycode == SDLK_RSHIFT ) )
|
if ((keycode == SDLK_LSHIFT) || (keycode == SDLK_RSHIFT))
|
||||||
{
|
{
|
||||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SHIFT;
|
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SHIFT;
|
||||||
unified[0] = ( phantom.ev.type == SDL_KEYDOWN );
|
unified[0] = (phantom.ev.type == SDL_KEYDOWN);
|
||||||
HotkeyInputHandler( &phantom );
|
HotkeyInputHandler(&phantom);
|
||||||
}
|
}
|
||||||
else if( ( keycode == SDLK_LCTRL ) || ( keycode == SDLK_RCTRL ) )
|
else if ((keycode == SDLK_LCTRL) || (keycode == SDLK_RCTRL))
|
||||||
{
|
{
|
||||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_CTRL;
|
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_CTRL;
|
||||||
unified[1] = ( phantom.ev.type == SDL_KEYDOWN );
|
unified[1] = (phantom.ev.type == SDL_KEYDOWN);
|
||||||
HotkeyInputHandler( &phantom );
|
HotkeyInputHandler(&phantom);
|
||||||
}
|
}
|
||||||
else if( ( keycode == SDLK_LALT ) || ( keycode == SDLK_RALT ) )
|
else if ((keycode == SDLK_LALT) || (keycode == SDLK_RALT))
|
||||||
{
|
{
|
||||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_ALT;
|
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_ALT;
|
||||||
unified[2] = ( phantom.ev.type == SDL_KEYDOWN );
|
unified[2] = (phantom.ev.type == SDL_KEYDOWN);
|
||||||
HotkeyInputHandler( &phantom );
|
HotkeyInputHandler(&phantom);
|
||||||
}
|
}
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
else if( ( keycode == SDLK_LGUI ) || ( keycode == SDLK_RGUI ) )
|
else if ((keycode == SDLK_LGUI) || (keycode == SDLK_RGUI))
|
||||||
#else // SDL 1.2
|
#else // SDL 1.2
|
||||||
else if( ( keycode == SDLK_LSUPER ) || ( keycode == SDLK_RSUPER ) || ( keycode == SDLK_LMETA ) || ( keycode == SDLK_RMETA) )
|
else if ((keycode == SDLK_LSUPER) || (keycode == SDLK_RSUPER) || (keycode == SDLK_LMETA) || (keycode == SDLK_RMETA))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SUPER;
|
phantom.ev.key.keysym.sym = (SDLKEY)UNIFIED_SUPER;
|
||||||
unified[3] = ( phantom.ev.type == SDL_KEYDOWN );
|
unified[3] = (phantom.ev.type == SDL_KEYDOWN);
|
||||||
HotkeyInputHandler( &phantom );
|
HotkeyInputHandler(&phantom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether we have any hotkeys registered for this particular keycode
|
// Check whether we have any hotkeys registered for this particular keycode
|
||||||
if( g_HotkeyMap.find(keycode) == g_HotkeyMap.end() )
|
if (g_HotkeyMap.find(keycode) == g_HotkeyMap.end())
|
||||||
return( IN_PASS );
|
return (IN_PASS);
|
||||||
|
|
||||||
// Inhibit the dispatch of hotkey events caused by real keys (not fake mouse button
|
// Inhibit the dispatch of hotkey events caused by real keys (not fake mouse button
|
||||||
// events) while the console is up.
|
// events) while the console is up.
|
||||||
|
|
||||||
bool consoleCapture = false;
|
bool consoleCapture = false;
|
||||||
|
|
||||||
if( g_Console->IsActive() && keycode < CUSTOM_SDL_KEYCODE )
|
if (g_Console->IsActive() && keycode < CUSTOM_SDL_KEYCODE)
|
||||||
consoleCapture = true;
|
consoleCapture = true;
|
||||||
|
|
||||||
// Here's an interesting bit:
|
// Here's an interesting bit:
|
||||||
@ -295,32 +289,32 @@ InReaction HotkeyInputHandler( const SDL_Event_* ev )
|
|||||||
std::vector<const char*> closestMapNames;
|
std::vector<const char*> closestMapNames;
|
||||||
size_t closestMapMatch = 0;
|
size_t closestMapMatch = 0;
|
||||||
|
|
||||||
for (std::vector<SHotkeyMapping>::iterator it = g_HotkeyMap[keycode].begin(); it < g_HotkeyMap[keycode].end(); ++it)
|
for (const SHotkeyMapping& hotkey : g_HotkeyMap[keycode])
|
||||||
{
|
{
|
||||||
// If a key has been pressed, and this event triggers on its release, skip it.
|
// If a key has been pressed, and this event triggers on its release, skip it.
|
||||||
// Similarly, if the key's been released and the event triggers on a keypress, skip it.
|
// Similarly, if the key's been released and the event triggers on a keypress, skip it.
|
||||||
if (it->negated == typeKeyDown)
|
if (hotkey.negated == typeKeyDown)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check for no unpermitted keys
|
// Check for no unpermitted keys
|
||||||
bool accept = true;
|
bool accept = true;
|
||||||
for (std::vector<SKey>::iterator itKey = it->requires.begin(); itKey != it->requires.end() && accept; ++itKey)
|
for (const SKey& k : hotkey.requires)
|
||||||
accept = isNegated(*itKey);
|
accept = isNegated(k);
|
||||||
|
|
||||||
if (accept && !(consoleCapture && it->name != "console.toggle"))
|
if (accept && !(consoleCapture && hotkey.name != "console.toggle"))
|
||||||
{
|
{
|
||||||
// Check if this is an equally precise or more precise match
|
// Check if this is an equally precise or more precise match
|
||||||
if (it->requires.size() + 1 >= closestMapMatch)
|
if (hotkey.requires.size() + 1 >= closestMapMatch)
|
||||||
{
|
{
|
||||||
// Check if more precise
|
// Check if more precise
|
||||||
if (it->requires.size() + 1 > closestMapMatch)
|
if (hotkey.requires.size() + 1 > closestMapMatch)
|
||||||
{
|
{
|
||||||
// Throw away the old less-precise matches
|
// Throw away the old less-precise matches
|
||||||
closestMapNames.clear();
|
closestMapNames.clear();
|
||||||
closestMapMatch = it->requires.size() + 1;
|
closestMapMatch = hotkey.requires.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
closestMapNames.push_back(it->name.c_str());
|
closestMapNames.push_back(hotkey.name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,25 +329,25 @@ InReaction HotkeyInputHandler( const SDL_Event_* ev )
|
|||||||
|
|
||||||
// -- KEYUP SECTION --
|
// -- KEYUP SECTION --
|
||||||
|
|
||||||
for (std::vector<SHotkeyMapping>::iterator it = g_HotkeyMap[keycode].begin(); it < g_HotkeyMap[keycode].end(); ++it)
|
for (const SHotkeyMapping& hotkey : g_HotkeyMap[keycode])
|
||||||
{
|
{
|
||||||
// If it's a keydown event, won't cause HotKeyUps in anything that doesn't
|
// If it's a keydown event, won't cause HotKeyUps in anything that doesn't
|
||||||
// use this key negated => skip them
|
// use this key negated => skip them
|
||||||
// If it's a keyup event, won't cause HotKeyUps in anything that does use
|
// If it's a keyup event, won't cause HotKeyUps in anything that does use
|
||||||
// this key negated => skip them too.
|
// this key negated => skip them too.
|
||||||
if (it->negated != typeKeyDown)
|
if (hotkey.negated != typeKeyDown)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check for no unpermitted keys
|
// Check for no unpermitted keys
|
||||||
bool accept = true;
|
bool accept = true;
|
||||||
for (std::vector<SKey>::iterator itKey = it->requires.begin(); itKey != it->requires.end() && accept; ++itKey)
|
for (const SKey& k : hotkey.requires)
|
||||||
accept = isNegated(*itKey);
|
accept = isNegated(k);
|
||||||
|
|
||||||
if (accept)
|
if (accept)
|
||||||
{
|
{
|
||||||
SDL_Event_ hotkeyNotification;
|
SDL_Event_ hotkeyNotification;
|
||||||
hotkeyNotification.ev.type = SDL_HOTKEYUP;
|
hotkeyNotification.ev.type = SDL_HOTKEYUP;
|
||||||
hotkeyNotification.ev.user.data1 = const_cast<char*>(it->name.c_str());
|
hotkeyNotification.ev.user.data1 = const_cast<char*>(hotkey.name.c_str());
|
||||||
in_push_priority_event(&hotkeyNotification);
|
in_push_priority_event(&hotkeyNotification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2012 Wildfire Games.
|
/* Copyright (C) 2015 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -43,6 +43,8 @@ extern int g_xres, g_yres;
|
|||||||
|
|
||||||
struct CProfileViewerInternals
|
struct CProfileViewerInternals
|
||||||
{
|
{
|
||||||
|
NONCOPYABLE(CProfileViewerInternals); // because of the ofstream
|
||||||
|
public:
|
||||||
CProfileViewerInternals() {}
|
CProfileViewerInternals() {}
|
||||||
|
|
||||||
/// Whether the profiling display is currently visible
|
/// Whether the profiling display is currently visible
|
||||||
@ -60,11 +62,6 @@ struct CProfileViewerInternals
|
|||||||
|
|
||||||
/// File for saved profile output (reset when the game is restarted)
|
/// File for saved profile output (reset when the game is restarted)
|
||||||
std::ofstream outputStream;
|
std::ofstream outputStream;
|
||||||
|
|
||||||
private:
|
|
||||||
// Cannot be copied/assigned, because of the ofstream
|
|
||||||
CProfileViewerInternals(const CProfileViewerInternals& rhs);
|
|
||||||
const CProfileViewerInternals& operator=(const CProfileViewerInternals& rhs);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,24 +392,24 @@ PSRETURN CXeromyces::CreateXMB(const xmlDocPtr doc, WriteBuffer& writeBuffer)
|
|||||||
i = 0;
|
i = 0;
|
||||||
u32 elementCount = (u32)elementNames.size();
|
u32 elementCount = (u32)elementNames.size();
|
||||||
writeBuffer.Append(&elementCount, 4);
|
writeBuffer.Append(&elementCount, 4);
|
||||||
for (it = elementNames.begin(); it != elementNames.end(); ++it)
|
for (const std::string& n : elementNames)
|
||||||
{
|
{
|
||||||
u32 textLen = (u32)it->length()+1;
|
u32 textLen = (u32)n.length()+1;
|
||||||
writeBuffer.Append(&textLen, 4);
|
writeBuffer.Append(&textLen, 4);
|
||||||
writeBuffer.Append((void*)it->c_str(), textLen);
|
writeBuffer.Append((void*)n.c_str(), textLen);
|
||||||
elementIDs[*it] = i++;
|
elementIDs[n] = i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output attribute names
|
// Output attribute names
|
||||||
i = 0;
|
i = 0;
|
||||||
u32 attributeCount = (u32)attributeNames.size();
|
u32 attributeCount = (u32)attributeNames.size();
|
||||||
writeBuffer.Append(&attributeCount, 4);
|
writeBuffer.Append(&attributeCount, 4);
|
||||||
for (it = attributeNames.begin(); it != attributeNames.end(); ++it)
|
for (const std::string& n : attributeNames)
|
||||||
{
|
{
|
||||||
u32 textLen = (u32)it->length()+1;
|
u32 textLen = (u32)n.length()+1;
|
||||||
writeBuffer.Append(&textLen, 4);
|
writeBuffer.Append(&textLen, 4);
|
||||||
writeBuffer.Append((void*)it->c_str(), textLen);
|
writeBuffer.Append((void*)n.c_str(), textLen);
|
||||||
attributeIDs[*it] = i++;
|
attributeIDs[n] = i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputElement(xmlDocGetRootElement(doc), writeBuffer, elementIDs, attributeIDs);
|
OutputElement(xmlDocGetRootElement(doc), writeBuffer, elementIDs, attributeIDs);
|
||||||
|
@ -276,8 +276,8 @@ CSoundManager::~CSoundManager()
|
|||||||
}
|
}
|
||||||
AL_CHECK;
|
AL_CHECK;
|
||||||
|
|
||||||
for (std::map<std::wstring, CSoundGroup*>::iterator it = m_SoundGroups.begin(); it != m_SoundGroups.end(); ++it)
|
for (const std::pair<std::wstring, CSoundGroup*>& p : m_SoundGroups)
|
||||||
delete it->second;
|
delete p.second;
|
||||||
m_SoundGroups.clear();
|
m_SoundGroups.clear();
|
||||||
|
|
||||||
if (m_PlayListItems)
|
if (m_PlayListItems)
|
||||||
|
Loading…
Reference in New Issue
Block a user