Addressed commit comments on a0e0ee3631

master
krzys-h 2015-07-16 20:09:06 +02:00
parent a0e0ee3631
commit 8a72f0a849
2 changed files with 36 additions and 28 deletions

View File

@ -22,6 +22,8 @@
#include "common/logger.h"
#include <boost/lexical_cast.hpp>
namespace
{
static EventType UNIQUE_EVENT_TYPE = EVENT_USER;
@ -459,8 +461,6 @@ void InitializeEventTypeTexts()
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAnear] = "EVENT_OBJECT_CAMERAnear";
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAaway] = "EVENT_OBJECT_CAMERAaway";
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT_MODE] = "EVENT_OBJECT_SHORTCUT_MODE";
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT] = "EVENT_OBJECT_SHORTCUT";
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT_MAX] = "EVENT_OBJECT_SHORTCUT_MAX";
EVENT_TYPE_TEXT[EVENT_OBJECT_MOVIELOCK] = "EVENT_OBJECT_MOVIELOCK";
EVENT_TYPE_TEXT[EVENT_OBJECT_EDITLOCK] = "EVENT_OBJECT_EDITLOCK";
EVENT_TYPE_TEXT[EVENT_OBJECT_LIMIT] = "EVENT_OBJECT_LIMIT";
@ -509,6 +509,16 @@ std::string ParseEventType(EventType eventType)
if (eventType < EVENT_STD_MAX)
{
if(eventType >= EVENT_INTERFACE_KEY && eventType <= EVENT_INTERFACE_KEY_END)
{
return "EVENT_INTERFACE_KEY"+boost::lexical_cast<std::string>(eventType-EVENT_INTERFACE_KEY);
}
if(eventType >= EVENT_OBJECT_SHORTCUT && eventType <= EVENT_OBJECT_SHORTCUT_MAX)
{
return "EVENT_OBJECT_SHORTCUT"+boost::lexical_cast<std::string>(eventType-EVENT_OBJECT_SHORTCUT);
}
const char* stdEvent = EVENT_TYPE_TEXT[eventType];
if (stdEvent[0] == 0)
return Other("STD_UNDEFINED");
@ -516,13 +526,10 @@ std::string ParseEventType(EventType eventType)
return stdEvent;
}
if(eventType >= EVENT_INTERFACE_KEY && eventType <= EVENT_INTERFACE_KEY_END)
{
return Other("EVENT_INTERFACE_KEY - EVENT_INTERFACE_KEY_END ");
}
if (eventType >= EVENT_USER)
{
return Other("USER_EVENT");
}
return Other("UNDEFINED");
}

View File

@ -73,7 +73,7 @@ bool CMainShort::CreateShortcuts()
}
m_shortcuts.clear();
// Display STOP / movie indicator
// Display pause / movie indicator
dim.x = 28.0f/640.0f;
dim.y = 28.0f/480.0f;
pos.x = 4.0f/640.0f;
@ -134,10 +134,10 @@ bool CMainShort::CreateShortcuts()
int icon = GetShortcutIcon(pObj->GetType());
if ( icon == -1 ) continue;
unsigned int team_index = std::find(teams.begin(), teams.end(), pObj->GetTeam()) - teams.begin();
unsigned int teamIndex = std::find(teams.begin(), teams.end(), pObj->GetTeam()) - teams.begin();
CShortcut* shortcut = m_interface->CreateShortcut(positions[team_index], dim, icon, static_cast<EventType>(EVENT_OBJECT_SHORTCUT+rank));
positions[team_index].x += dim.x;
CShortcut* shortcut = m_interface->CreateShortcut(positions[teamIndex], dim, icon, static_cast<EventType>(EVENT_OBJECT_SHORTCUT+rank));
positions[teamIndex].x += dim.x;
m_shortcuts.push_back(pObj);
std::string tooltipName;
@ -258,26 +258,27 @@ void CMainShort::SelectNext()
CObject* pPrev = m_main->DeselectAll();
unsigned int i = 0;
auto it = std::find(m_shortcuts.begin(), m_shortcuts.end(), pPrev);
if (it != m_shortcuts.end())
{
i = it-m_shortcuts.begin();
i++;
if (i >= m_shortcuts.size())
{
i = 0;
}
}
if(i < m_shortcuts.size())
{
m_main->SelectObject(m_shortcuts[i]);
}
else
if(m_shortcuts.size() == 0)
{
m_main->SelectHuman();
return;
}
// Find the current object in the list
auto it = std::find(m_shortcuts.begin(), m_shortcuts.end(), pPrev);
// Get the next one
if (it != m_shortcuts.end())
{
++it;
}
// If there is no more left, return to the first one
if (it == m_shortcuts.end())
{
it = m_shortcuts.begin();
}
m_main->SelectObject(*it);
}