Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy

This commit is contained in:
Simon Robertshaw 2013-07-28 10:30:45 +01:00
commit 387424e007
8 changed files with 42 additions and 21 deletions

View File

@ -394,10 +394,10 @@ void EngineProcess()
engine->Exit();
break;
case SDL_KEYDOWN:
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_LSHIFT, event.key.keysym.mod&KEY_MOD_LCONTROL, event.key.keysym.mod&KEY_MOD_LALT);
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_SHIFT, event.key.keysym.mod&KEY_MOD_CONTROL, event.key.keysym.mod&KEY_MOD_ALT);
break;
case SDL_KEYUP:
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_LSHIFT, event.key.keysym.mod&KEY_MOD_LCONTROL, event.key.keysym.mod&KEY_MOD_LALT);
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KEY_MOD_SHIFT, event.key.keysym.mod&KEY_MOD_CONTROL, event.key.keysym.mod&KEY_MOD_ALT);
break;
case SDL_MOUSEMOTION:
engine->onMouseMove(event.motion.x*inputScale, event.motion.y*inputScale);

View File

@ -1279,11 +1279,13 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
switch(key)
{
case KEY_ALT:
case KEY_LALT:
case KEY_RALT:
drawSnap = true;
enableAltBehaviour();
break;
case KEY_CTRL:
case KEY_LCTRL:
case KEY_RCTRL:
if(!isMouseDown)
{
if(drawModeReset)
@ -1302,7 +1304,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
enableCtrlBehaviour();
break;
case KEY_SHIFT:
case KEY_LSHIFT:
case KEY_RSHIFT:
if(!isMouseDown)
{
if(drawModeReset)
@ -1500,14 +1503,17 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
drawModeReset = true;
switch(key)
{
case KEY_ALT:
case KEY_LALT:
case KEY_RALT:
drawSnap = false;
disableAltBehaviour();
break;
case KEY_CTRL:
case KEY_LCTRL:
case KEY_RCTRL:
disableCtrlBehaviour();
break;
case KEY_SHIFT:
case KEY_LSHIFT:
case KEY_RSHIFT:
disableShiftBehaviour();
break;
case 'z':

View File

@ -14,9 +14,12 @@
#define KEY_ENTER SDLK_KP_ENTER
#define KEY_ESCAPE SDLK_ESCAPE
#define KEY_CTRL SDLK_LCTRL
#define KEY_ALT SDLK_LALT
#define KEY_SHIFT SDLK_LSHIFT
#define KEY_LCTRL SDLK_LCTRL
#define KEY_LALT SDLK_LALT
#define KEY_LSHIFT SDLK_LSHIFT
#define KEY_RCTRL SDLK_RCTRL
#define KEY_RALT SDLK_RALT
#define KEY_RSHIFT SDLK_RSHIFT
#define KEY_MOD_NONE KMOD_NONE
#define KEY_MOD_LSHIFT KMOD_LSHIFT
@ -32,9 +35,9 @@
#define KEY_MOD_MODE KMOD_MODE
#define KEY_MOD_RESERVED KMOD_RESERVED
#define KEY_MOD_CONTROL KEY_MOD_RCONTROL | KEY_MOD_LCONTROL
#define KEY_MOD_ALT KEY_MOD_RALT | KEY_MOD_LALT
#define KEY_MOD_SHIFT KEY_MOD_RSHIFT | KEY_MOD_LSHIFT
#define KEY_MOD_CONTROL (KEY_MOD_RCONTROL | KEY_MOD_LCONTROL)
#define KEY_MOD_ALT (KEY_MOD_RALT | KEY_MOD_LALT)
#define KEY_MOD_SHIFT (KEY_MOD_RSHIFT | KEY_MOD_LSHIFT)
#define KEY_a SDLK_a
#define KEY_d SDLK_d

View File

@ -201,13 +201,18 @@ void LocalBrowserView::OnMouseWheel(int x, int y, int d)
else
c->PrevPage();
}
void LocalBrowserView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if(key == KEY_ESCAPE)
c->Exit();
if (key == KEY_CTRL)
else if (key == KEY_LCTRL || key == KEY_RCTRL)
c->SetMoveToFront(false);
else
}
void LocalBrowserView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if (key == KEY_LCTRL || key == KEY_RCTRL)
c->SetMoveToFront(true);
}

View File

@ -31,6 +31,7 @@ public:
void NotifySelectedChanged(LocalBrowserModel * sender);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual ~LocalBrowserView();
};

View File

@ -574,10 +574,10 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
tempUsername = new ui::Label(ui::Point(5, currentY+3), ui::Point(Size.X-((XRES/2) + 13), 16), comments->at(i)->authorNameFormatted);
tempUsername->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempUsername->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
if (sender->GetSave() && sender->GetSave()->GetUserName() == comments->at(i)->authorName)
tempUsername->SetTextColour(ui::Colour(255, 100, 100));
else if (Client::Ref().GetAuthUser().ID && Client::Ref().GetAuthUser().Username == comments->at(i)->authorName)
if (Client::Ref().GetAuthUser().ID && Client::Ref().GetAuthUser().Username == comments->at(i)->authorName)
tempUsername->SetTextColour(ui::Colour(255, 255, 100));
else if (sender->GetSave() && sender->GetSave()->GetUserName() == comments->at(i)->authorName)
tempUsername->SetTextColour(ui::Colour(255, 100, 100));
currentY += 16;
commentComponents.push_back(tempUsername);

View File

@ -714,7 +714,12 @@ void SearchView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bo
{
if (key == KEY_ESCAPE)
c->Exit();
if (ctrl)
c->InstantOpen(ctrl);
else if (key == KEY_LCTRL || key == KEY_RCTRL)
c->InstantOpen(true);
}
void SearchView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if (key == KEY_LCTRL || key == KEY_RCTRL)
c->InstantOpen(false);
}

View File

@ -68,6 +68,7 @@ public:
virtual void OnTick(float dt);
virtual void OnMouseWheel(int x, int y, int d);
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
};