#include "generic/callback.h"
#include "string/string.h"
#include "stream/stringstream.h"
+
#include "scenelib.h"
#include "eclasslib.h"
#include "renderer.h"
return modifiers;
}
+inline unsigned int buttons_for_button_and_modifiers(ButtonIdentifier button, ModifierFlags flags)
+{
+ unsigned int buttons = 0;
+
+ switch (button.get())
+ {
+ case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break;
+ case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break;
+ case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break;
+ }
+
+ if(bitfield_enabled(flags, c_modifierControl))
+ buttons |= RAD_CONTROL;
+
+ if(bitfield_enabled(flags, c_modifierShift))
+ buttons |= RAD_SHIFT;
+
+ if(bitfield_enabled(flags, c_modifierAlt))
+ buttons |= RAD_ALT;
+
+ return buttons;
+}
+
inline unsigned int buttons_for_event_button(GdkEventButton* event)
{
unsigned int flags = 0;
{
if(event->type == GDK_BUTTON_PRESS)
{
- xywnd->XY_MouseDown(static_cast<int>(event->x), static_cast<int>(event->y), buttons_for_event_button(event));
+ g_pParentWnd->SetActiveXY(xywnd);
+
+ xywnd->ButtonState_onMouseDown(buttons_for_event_button(event));
+
+ xywnd->onMouseDown(WindowVector(event->x, event->y), button_for_button(event->button), modifiers_for_state(event->state));
}
return FALSE;
}
if(event->type == GDK_BUTTON_RELEASE)
{
xywnd->XY_MouseUp(static_cast<int>(event->x), static_cast<int>(event->y), buttons_for_event_button(event));
+
+ xywnd->ButtonState_onMouseUp(buttons_for_event_button(event));
}
return FALSE;
}
AddCameraMovedCallback(ReferenceCaller<XYWnd, &XYWnd_CameraMoved>(*this));
PressedButtons_connect(g_pressedButtons, m_gl_widget);
+
+ onMouseDown.connectLast(makeSignalHandler3(MouseDownCaller(), *this));
}
XYWnd::~XYWnd()
{
+ onDestroyed();
+
if(m_mnuDrop != 0)
{
gtk_widget_destroy(GTK_WIDGET(m_mnuDrop));
void entitycreate_activated(GtkWidget* item)
{
- g_pParentWnd->ActiveXY()->OnEntityCreate(gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child)));
+ scene::Node* world_node = Map_FindWorldspawn(g_map);
+ const char* entity_name = gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child));
+
+ if(!(world_node && string_equal(entity_name, "worldspawn")))
+ {
+ g_pParentWnd->ActiveXY()->OnEntityCreate(entity_name);
+ } else {
+ GlobalRadiant().m_pfnMessageBox(GTK_WIDGET(MainFrame_getWindow()), "There's already a worldspawn in your map!"
+ "",
+ "Info",
+ eMB_OK,
+ eMB_ICONDEFAULT);
+ }
}
void EntityClassMenu_addItem(GtkMenu* menu, const char* name)
return WindowVector(static_cast<float>(x), static_cast<float>(y));
}
+void XYWnd::mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers)
+{
+ XY_MouseDown(static_cast<int>(position.x()), static_cast<int>(position.y()), buttons_for_button_and_modifiers(button, modifiers));
+}
void XYWnd::XY_MouseDown (int x, int y, unsigned int buttons)
{
- g_pParentWnd->SetActiveXY(this);
-
- ButtonState_onMouseDown(buttons);
-
if(buttons == Move_buttons())
{
Move_Begin();
{
m_window_observer->onMouseUp(WindowVector_forInteger(x, y), button_for_flags(buttons), modifiers_for_flags(buttons));
}
-
- ButtonState_onMouseUp(buttons);
}
void XYWnd::XY_MouseMoved (int x, int y, unsigned int buttons)
glLoadMatrixf(reinterpret_cast<const float*>(&m_modelview));
- unsigned int globalstate = RENDER_COLOUR | RENDER_COLOURWRITE;
+ unsigned int globalstate = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_POLYGONSMOOTH | RENDER_LINESMOOTH;
if(!g_xywindow_globals.m_bNoStipple)
{
globalstate |= RENDER_LINESTIPPLE;
GlobalPreferenceSystem().registerPreference("SI_ShowOutlines", BoolImportStringCaller(g_xywindow_globals_private.show_outline), BoolExportStringCaller(g_xywindow_globals_private.show_outline));
GlobalPreferenceSystem().registerPreference("SI_ShowAxis", BoolImportStringCaller(g_xywindow_globals_private.show_axis), BoolExportStringCaller(g_xywindow_globals_private.show_axis));
GlobalPreferenceSystem().registerPreference("CamXYUpdate", BoolImportStringCaller(g_xywindow_globals_private.m_bCamXYUpdate), BoolExportStringCaller(g_xywindow_globals_private.m_bCamXYUpdate));
+ GlobalPreferenceSystem().registerPreference("ShowWorkzone", BoolImportStringCaller(g_xywindow_globals_private.d_show_work), BoolExportStringCaller(g_xywindow_globals_private.d_show_work));
GlobalPreferenceSystem().registerPreference("SI_AxisColors0", Vector3ImportStringCaller(g_xywindow_globals.AxisColorX), Vector3ExportStringCaller(g_xywindow_globals.AxisColorX));
GlobalPreferenceSystem().registerPreference("SI_AxisColors1", Vector3ImportStringCaller(g_xywindow_globals.AxisColorY), Vector3ExportStringCaller(g_xywindow_globals.AxisColorY));