Skip to content

Commit

Permalink
Removing unneeded bits from main master merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bradallred committed May 25, 2016
1 parent 579dd8f commit fc62088
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 156 deletions.
1 change: 0 additions & 1 deletion gemrb/GUIScripts/GUIClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class GWindow(GView):
'SetupEquipmentIcons': _GemRB.Window_SetupEquipmentIcons,
'SetupControls': _GemRB.Window_SetupControls,
'Focus': _GemRB.Window_Focus,
'SetKeyPressEvent': _GemRB.Window_SetKeyPressEvent,
'ShowModal': _GemRB.Window_ShowModal,
}

Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/GUI/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ void Button::OnMouseUp(const Point& p, unsigned short Button, unsigned short Mod
return;
}

if (Button & GEM_MB_ACTION) {
if ((Button&GEM_MB_NORMAL) == GEM_MB_ACTION) {
if ((Mod & GEM_MOD_SHIFT) && eventHandlers[IE_GUI_BUTTON_ON_SHIFT_PRESS])
RunEventHandler( eventHandlers[IE_GUI_BUTTON_ON_SHIFT_PRESS] );
else
Expand Down
117 changes: 59 additions & 58 deletions gemrb/core/GUI/GameControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,73 +1841,74 @@ void GameControl::OnMouseUp(const Point& mp, unsigned short Button, unsigned sho
actor = NULL;
}
}

if (Button & GEM_MB_ACTION) {
if (!actor) {
Actor *pc = core->GetFirstSelectedPC(false);
if (!pc) {
//this could be a non-PC
pc = game->selected[0];
}
//add a check if you don't want some random monster handle doors and such
if (overDoor) {
HandleDoor(overDoor, pc);
goto formation_handling;
}
if (overContainer) {
HandleContainer(overContainer, pc);
goto formation_handling;
}
if (overInfoPoint) {
if (overInfoPoint->Type==ST_TRAVEL) {
ieDword exitID = overInfoPoint->GetGlobalID();
if (core->HasFeature(GF_TEAM_MOVEMENT)) {
// pst forces everyone to travel (eg. ar0201 outside_portal)
int i = game->GetPartySize(false);
while(i--) {
game->GetPC(i, false)->UseExit(exitID);
}
} else {
int i = game->selected.size();
while(i--) {
game->selected[i]->UseExit(exitID);
switch (Button) {
case GEM_MB_ACTION:
if (!actor) {
Actor *pc = core->GetFirstSelectedPC(false);
if (!pc) {
//this could be a non-PC
pc = game->selected[0];
}
//add a check if you don't want some random monster handle doors and such
if (overDoor) {
HandleDoor(overDoor, pc);
break;
}
if (overContainer) {
HandleContainer(overContainer, pc);
break;
}
if (overInfoPoint) {
if (overInfoPoint->Type==ST_TRAVEL) {
ieDword exitID = overInfoPoint->GetGlobalID();
if (core->HasFeature(GF_TEAM_MOVEMENT)) {
// pst forces everyone to travel (eg. ar0201 outside_portal)
int i = game->GetPartySize(false);
while(i--) {
game->GetPC(i, false)->UseExit(exitID);
}
} else {
int i = game->selected.size();
while(i--) {
game->selected[i]->UseExit(exitID);
}
}
}
if (HandleActiveRegion(overInfoPoint, pc, p)) {
core->SetEventFlag(EF_RESETTARGET);
break;
}
}
if (HandleActiveRegion(overInfoPoint, pc, p)) {
core->SetEventFlag(EF_RESETTARGET);
goto formation_handling;
//just a single actor, no formation
if (game->selected.size()==1
&& target_mode == TARGET_MODE_CAST
&& spellCount
&& (target_types&GA_POINT)) {
//the player is using an item or spell on the ground
TryToCast(pc, p);
break;
}
}
//just a single actor, no formation
if (game->selected.size()==1
&& target_mode == TARGET_MODE_CAST
&& spellCount
&& (target_types&GA_POINT)) {
//the player is using an item or spell on the ground
TryToCast(pc, p);
goto formation_handling;
doMove = (!actor && target_mode == TARGET_MODE_NONE);
break;
case GEM_MB_MENU:
// we used to check mod in this case,
// but it doesnt make sense to initiate an action based on a mod on mouse down
// then cancel that action because the mod disapeared before mouse up
if (!core->HasFeature(GF_HAS_FLOAT_MENU)) {
SetTargetMode(TARGET_MODE_NONE);
}
if (!actor) {
// reset the action bar
core->GetGUIScriptEngine()->RunFunction("GUICommonWindows", "EmptyControls");
core->SetEventFlag(EF_ACTION);
}
}
doMove = (!actor && target_mode == TARGET_MODE_NONE);
} else if (Button & GEM_MB_MENU) {
// we used to check mod in this case,
// but it doesnt make sense to initiate an action based on a mod on mouse down
// then cancel that action because the mod disapeared before mouse up
if (!core->HasFeature(GF_HAS_FLOAT_MENU)) {
SetTargetMode(TARGET_MODE_NONE);
}
if (!actor) {
// reset the action bar
core->GetGUIScriptEngine()->RunFunction("GUICommonWindows", "EmptyControls");
core->SetEventFlag(EF_ACTION);
}
} else {
return; // we dont handle any other buttons beyond this point
break;
default:
return; // we dont handle any other buttons beyond this point
}
}

formation_handling:
if (doMove && game->selected.size() > 0) {
// construct a sorted party
// TODO: this is still ugly, help?
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/GUI/MapControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void MapControl::OnMouseUp(const Point& p, unsigned short Button, unsigned short
return;
case MAP_VIEW_NOTES:
//left click allows setting only when in MAP_SET_NOTE mode
if (Button & GEM_MB_ACTION) {
if (Button == GEM_MB_ACTION) {
ViewHandle(p.x, p.y);
}
ClickHandle(Button);
Expand Down
1 change: 0 additions & 1 deletion gemrb/core/GUI/ScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ void ScrollBar::OnMouseUp(const Point&, unsigned short /*Button*/, unsigned shor
MarkDirty();
State = 0;
Frames[IE_GUI_SCROLLBAR_SLIDER]->YPos = 0; //this is to clear any offset incurred by grabbing the slider

}

/** Mousewheel scroll */
Expand Down
15 changes: 1 addition & 14 deletions gemrb/core/GUI/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ void Window::DispatchMouseDown(View* target, const Point& p, unsigned short butt
trackingView = target; // all views track the mouse within their bounds
}

void Window::SetKeyPressEvent(WindowKeyPressHandler handler) {
keyPressHandler = handler;
}

void Window::DispatchMouseUp(View* target, const Point& p, unsigned short button, unsigned short mod)
{
if (isDragging) {
Expand Down Expand Up @@ -377,16 +373,7 @@ bool Window::OnKeyPress(const KeyboardEvent& key, unsigned short mod)
Close();
return true;
}

if(keyPressHandler) {
WindowKeyPress wkp;
wkp.key = key;
wkp.mod = mod;

return keyPressHandler(wkp);
} else {
return ScrollView::OnKeyPress(key, mod);
}
return ScrollView::OnKeyPress(key, mod);
}

void Window::OnMouseLeave(const Point&, const DragOp*)
Expand Down
19 changes: 0 additions & 19 deletions gemrb/core/GUI/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ namespace GemRB {
class Control;
class Sprite2D;


struct WindowKeyPress {
unsigned short key;
unsigned short mod;
};

class WindowKeyPressHandler : public Holder< Callback<WindowKeyPress&, bool> > {
public:
WindowKeyPressHandler(Callback<WindowKeyPress&, bool>* ptr = NULL)
: Holder< Callback<WindowKeyPress&, bool> >(ptr) {}

bool operator()(WindowKeyPress &wkp) {
return (*ptr)(wkp);
}
};

/**
* @class Window
* Class serving as a container for Control/widget objects
Expand Down Expand Up @@ -100,8 +84,6 @@ class GEM_EXPORT Window : public ScrollView {
void Focus();
bool DisplayModal(WindowManager::ModalShadow = WindowManager::ShadowNone);


void SetKeyPressEvent(WindowKeyPressHandler handler);
/** Sets 'ctrl' as Focused */
void SetFocused(Control* ctrl);
void SetPosition(WindowPosition);
Expand All @@ -128,7 +110,6 @@ class GEM_EXPORT Window : public ScrollView {
private:
void RecreateBuffer();

WindowKeyPressHandler keyPressHandler;
private: // Private attributes
/** Controls Array */
std::vector< Control*> Controls;
Expand Down
38 changes: 0 additions & 38 deletions gemrb/plugins/GUIScript/GUIScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,43 +1638,6 @@ static PyObject* GemRB_Control_SetText(PyObject* self, PyObject* args)
Py_RETURN_NONE;
}

PyDoc_STRVAR( GemRB_Window_SetKeyPressEvent__doc,
"===== Window_SetKeyPressEvent =====\n\
\n\
**Prototype:** _GemRB.Window_SetKeyPressEvent (callback)\n\
\n\
**Description:** Sets a callback function to handle key press event on window scopes. \n\
\n\
**Parameters:**\n\
* callback - Python function that accepts (key, mod) arguments and returns\n\
* 1 indicating succesful key press consumption or 0 otherwise. \n\
\n\
**Return value:** N/A\n\
\n\
**Example:**\n\
Window.SetKeyPressEvent (KeyPressCallback)\n\
return\n\
\n\
**See also:** [[guiscript:QuitGame]]\n\
"
);

static PyObject* GemRB_Window_SetKeyPressEvent(PyObject *self, PyObject *args) {
PyObject *fn;

PARSE_ARGS2(args, "OO", &self, &fn);

WindowKeyPressHandler handler = NULL;
if(fn != Py_None && PyCallable_Check(fn)) {
handler = new PythonObjectCallback<WindowKeyPress&, bool>(fn);
}

Window *window = GetView<Window>(self);
window->SetKeyPressEvent(handler);

Py_RETURN_NONE;
}

PyDoc_STRVAR( GemRB_TextArea_Append__doc,
"===== TextArea_Append =====\n\
\n\
Expand Down Expand Up @@ -13233,7 +13196,6 @@ static PyMethodDef GemRBInternalMethods[] = {
METHOD(Window_Close, METH_VARARGS),
METHOD(Window_DeleteControl, METH_VARARGS),
METHOD(Window_Focus, METH_VARARGS),
METHOD(Window_SetKeyPressEvent, METH_VARARGS),
METHOD(Window_SetupControls, METH_VARARGS),
METHOD(Window_SetupEquipmentIcons, METH_VARARGS),
METHOD(Window_ShowModal, METH_VARARGS),
Expand Down
14 changes: 0 additions & 14 deletions gemrb/plugins/GUIScript/PythonHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "GUI/GUIScriptInterface.h"
#include "PythonHelpers.h"
#include "GUI/Window.h"

using namespace GemRB;

Expand Down Expand Up @@ -76,19 +75,6 @@ void PythonObjectCallback<Control*, void>::operator() (Control* ctrl) const
CallPython(Function, args);
}

template <>
bool PythonObjectCallback<WindowKeyPress&, bool>::operator() (WindowKeyPress &wkp) const {
if (!Function || !Py_IsInitialized()) {
return false;
}

PyObject *args = PyTuple_Pack(2, PyInt_FromLong(wkp.key),
PyInt_FromLong(wkp.mod));
long result = CallPythonWithReturn(Function, args);

return result > 0;
}

static PyObject* CallPythonObject(PyObject *Function, PyObject *args) {
if (!Function) {
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion gemrb/plugins/SDLVideo/SDLVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace GemRB;
SDLVideoDriver::SDLVideoDriver(void)
{
lastTime = 0;
lastMouseDownTime = lastMouseMoveTime = GetTickCount();
lastMouseDownTime = GetTickCount();
}

SDLVideoDriver::~SDLVideoDriver(void)
Expand Down
9 changes: 1 addition & 8 deletions gemrb/plugins/SDLVideo/SDLVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,8 @@ inline int GetModState(int modstate)
return value;
}

inline int GetModState()
{
return GetModState(SDL_GetModState());
}

class SDLVideoDriver : public Video {
protected:
unsigned long lastTime;
unsigned long lastMouseMoveTime;
unsigned long lastMouseDownTime;

public:
Expand All @@ -84,7 +77,7 @@ class SDLVideoDriver : public Video {
virtual bool ToggleGrabInput()=0;
virtual void ShowSoftKeyboard()=0;
virtual void HideSoftKeyboard()=0;

void InitSpriteCover(SpriteCover* sc, int flags);
void AddPolygonToSpriteCover(SpriteCover* sc, Wall_Polygon* poly);
void DestroySpriteCover(SpriteCover* sc);
Expand Down

0 comments on commit fc62088

Please sign in to comment.