[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 388 - in trunk/src: . scripting
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 388 - in trunk/src: . scripting |
Date: |
Fri, 04 Jun 2004 01:42:17 +0200 |
Author: grumbel
Date: 2004-06-04 01:42:17 +0200 (Fri, 04 Jun 2004)
New Revision: 388
Modified:
trunk/src/editor_map_component.cxx
trunk/src/editor_map_component.hxx
trunk/src/flexlay_wrap.i
trunk/src/menu.cxx
trunk/src/python_functor.cxx
trunk/src/python_functor.hxx
trunk/src/scripting/editor.cxx
trunk/src/scripting/editor.hxx
trunk/src/supertux.py
trunk/src/workspace.cxx
Log:
- added mouse coordinates to keyboard bindings
Modified: trunk/src/editor_map_component.cxx
===================================================================
--- trunk/src/editor_map_component.cxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/editor_map_component.cxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -20,6 +20,7 @@
#include <iostream>
#include <ClanLib/Core/core_iostream.h>
#include <ClanLib/Display/keyboard.h>
+#include <ClanLib/Display/mouse.h>
#include <ClanLib/Display/display.h>
#include <ClanLib/Display/display_iostream.h>
#include <ClanLib/Display/keys.h>
@@ -41,7 +42,7 @@
Scrollbar* scrollbar_v;
CL_SlotContainer slots;
Workspace workspace;
- CL_Signal_v0 key_bindings[256];
+ CL_Signal_v2<int, int> key_bindings[256];
void draw();
void mouse_up (const CL_InputEvent& event);
@@ -100,7 +101,11 @@
EditorMapComponentImpl::on_key_down(const CL_InputEvent& event)
{
if (event.id >= 0 && event.id < 256)
- key_bindings[event.id]();
+ {
+ CL_Rect rect = parent->get_position();
+ key_bindings[event.id](CL_Mouse::get_x() - rect.left,
+ CL_Mouse::get_y() - rect.top);
+ }
}
void
@@ -193,7 +198,7 @@
impl->workspace.get_gc_state().set_pos(CL_Pointf(impl->workspace.get_gc_state().get_pos().x,
y));
}
-CL_Signal_v0&
+CL_Signal_v2<int, int>&
EditorMapComponent::sig_on_key(const std::string& str)
{
int id = CL_Keyboard::get_device().keyid_to_string(str);
Modified: trunk/src/editor_map_component.hxx
===================================================================
--- trunk/src/editor_map_component.hxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/editor_map_component.hxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -62,7 +62,7 @@
void move_to_x(float x);
void move_to_y(float y);
- CL_Signal_v0& sig_on_key(const std::string& str);
+ CL_Signal_v2<int, int>& sig_on_key(const std::string& str);
CL_Point screen2world(const CL_Point& pos);
Modified: trunk/src/flexlay_wrap.i
===================================================================
--- trunk/src/flexlay_wrap.i 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/flexlay_wrap.i 2004-06-03 23:42:17 UTC (rev 388)
@@ -108,4 +108,5 @@
%include "netpanzer.hxx"
+
/* EOF */
Modified: trunk/src/menu.cxx
===================================================================
--- trunk/src/menu.cxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/menu.cxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -209,7 +209,10 @@
MenuImpl::on_mouse_down(const CL_InputEvent& event)
{
if (current_item != -1)
- items[current_item]->sig_clicked()();
+ {
+ std::cout << "Current_Item: " << current_item << std::endl;
+ items[current_item]->sig_clicked()();
+ }
parent->release_mouse();
parent->show(false);
}
Modified: trunk/src/python_functor.cxx
===================================================================
--- trunk/src/python_functor.cxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/python_functor.cxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -87,4 +87,21 @@
}
}
+void
+PythonFunctor::operator()(int x, int y)
+{
+ if (obj)
+ {
+ PyObject* arglist = Py_BuildValue("(i, i)", x, y);
+ if (PyEval_CallObject(obj, arglist) == 0)
+ {
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ }
+ //Py_DECREF(arglist);
+ }
+}
+
/* EOF */
Modified: trunk/src/python_functor.hxx
===================================================================
--- trunk/src/python_functor.hxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/python_functor.hxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -38,6 +38,7 @@
void operator()();
void operator()(int i);
+ void operator()(int x, int y);
};
#endif
Modified: trunk/src/scripting/editor.cxx
===================================================================
--- trunk/src/scripting/editor.cxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/scripting/editor.cxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -37,6 +37,12 @@
new CL_Slot(sig.connect_functor(PythonFunctor(obj)));
}
+void connect_v2(CL_Signal_v2<int, int>& sig, PyObject* obj)
+{
+ sig = CL_Signal_v2<int, int>();
+ new CL_Slot(sig.connect_functor(PythonFunctor(obj)));
+}
+
CL_Sprite
make_sprite(const std::string& filename)
{
Modified: trunk/src/scripting/editor.hxx
===================================================================
--- trunk/src/scripting/editor.hxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/scripting/editor.hxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -31,6 +31,7 @@
void connect(CL_Signal_v0& sig, PyObject* obj);
void connect_v1(CL_Signal_v1<int>& sig, PyObject* obj);
+void connect_v2(CL_Signal_v2<int, int>& sig, PyObject* obj);
CL_Sprite make_sprite(const std::string& filename);
Tile make_tile(const char* filename,
Modified: trunk/src/supertux.py
===================================================================
--- trunk/src/supertux.py 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/supertux.py 2004-06-03 23:42:17 UTC (rev 388)
@@ -422,7 +422,11 @@
recent_files_menu = Menu(CL_Point(32*2, 54), gui.get_component())
for filename in config.recent_files:
- recent_files_menu.add_item(mysprite, filename, lambda:
supertux_load_level(filename))
+ print filename
+ fun = lambda: sys.stdout.write("bla bla: %s\n" % filename)
+ fun()
+ recent_files_menu.add_item(mysprite, filename, fun)
+ #supertux_load_level(filename))
minimap = Minimap(editor_map, CL_Rect(CL_Point(3, 488+3-14),
CL_Size(794-134-16, 50)), editor_map)
@@ -693,7 +697,7 @@
pos = gc.get_pos()
gc.set_zoom(zoom)
gc.set_pos(pos)
-
+
menu.add_item("Zoom/1:4 (25%) ", lambda: gui_set_zoom(0.25))
menu.add_item("Zoom/1:2 (50%) ", lambda: gui_set_zoom(0.5))
menu.add_item("Zoom/1:1 (100%) ", lambda: gui_set_zoom(1.0))
@@ -724,14 +728,17 @@
gui_show_current()
set_tilemap_paint_tool()
-connect(editor_map.sig_on_key("f1"), lambda: gui_toggle_minimap())
-connect(editor_map.sig_on_key("m"), lambda: gui_toggle_minimap())
-connect(editor_map.sig_on_key("g"), lambda: gui_toggle_grid())
-connect(editor_map.sig_on_key("4"), lambda: gui_toggle_display_props())
-connect(editor_map.sig_on_key("3"), lambda: gui_show_foreground())
-connect(editor_map.sig_on_key("2"), lambda: gui_show_interactive())
-connect(editor_map.sig_on_key("1"), lambda: gui_show_background())
+connect_v2(editor_map.sig_on_key("f1"), lambda x, y: gui_toggle_minimap())
+connect_v2(editor_map.sig_on_key("m"), lambda x, y: gui_toggle_minimap())
+connect_v2(editor_map.sig_on_key("g"), lambda x, y: gui_toggle_grid())
+connect_v2(editor_map.sig_on_key("4"), lambda x, y: gui_toggle_display_props())
+connect_v2(editor_map.sig_on_key("3"), lambda x, y: gui_show_foreground())
+connect_v2(editor_map.sig_on_key("2"), lambda x, y: gui_show_interactive())
+connect_v2(editor_map.sig_on_key("1"), lambda x, y: gui_show_background())
+connect_v2(editor_map.sig_on_key("5"), lambda x, y:
editor_map.zoom_in(CL_Point(x, y)))
+connect_v2(editor_map.sig_on_key("6"), lambda x, y:
editor_map.zoom_out(CL_Point(x, y)))
+
gui.run()
del config
Modified: trunk/src/workspace.cxx
===================================================================
--- trunk/src/workspace.cxx 2004-06-03 22:41:47 UTC (rev 387)
+++ trunk/src/workspace.cxx 2004-06-03 23:42:17 UTC (rev 388)
@@ -35,13 +35,6 @@
{
public:
GraphicContextState gc_state;
-
- bool scrolling;
- CL_Point click_pos;
-
- /** Position of the center */
- CL_Pointf old_trans_offset;
-
EditorMap editor_map;
Tool tool;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 388 - in trunk/src: . scripting,
Ingo Ruhnke <=