示例#1
0
static void
cursor_release_method(HosOrnament *self)
{
  HosCursor *cursor = HOS_CURSOR(self);
  g_signal_emit_by_name(cursor, "dropped", cursor_get_position(cursor));

  if (HOS_ORNAMENT_CLASS(hos_cursor_parent_class)->release)
    (HOS_ORNAMENT_CLASS(hos_cursor_parent_class)->release)(self);

}
示例#2
0
void ClientSystem::frameTrigger(int curtime)
{
    if (scenarioStarted())
    {
        float delta = float(curtime)/1000.0f;

        /* turn if mouse is at borders */
        float x, y;
        cursor_get_position(x, y);

        /* do not scroll with mouse */
        if (cursor_exists) x = y = 0.5;

        /* turning */
        gameent *fp = (gameent*)player;
        float fs;
        lua::pop_external_ret(lua::call_external_ret("entity_get_attr", "is",
            "f", ClientSystem::playerLogicEntity->getUniqueId(), "facing_speed", &fs));
        if (fp->turn_move || fabs(x - 0.5) > 0.495)
        {
            player->yaw += fs * (
                fp->turn_move ? fp->turn_move : (x > 0.5 ? 1 : -1)
            ) * delta;
        }

        if (fp->look_updown_move || fabs(y - 0.5) > 0.495)
        {
            player->pitch += fs * (
                fp->look_updown_move ? fp->look_updown_move : (y > 0.5 ? -1 : 1)
            ) * delta;
        }

        /* normalize and limit the yaw and pitch values to appropriate ranges */
        extern void fixcamerarange();
        fixcamerarange();

        TargetingControl::determineMouseTarget();
    }
}
示例#3
0
static void
hos_cursor_get_property (GObject         *object,
			 guint            prop_id,
			 GValue          *value,
			 GParamSpec      *pspec)
{
  switch (prop_id)
    {
    case PROP_POSITION:
      g_value_set_double(value, cursor_get_position(HOS_CURSOR(object)));
      break;
    case PROP_ADJUSTMENT:
      g_value_set_object(value, G_OBJECT(cursor_get_adjustment(HOS_CURSOR(object))));
      break;
    case PROP_ORIENTATION:
      g_value_set_enum(value, HOS_CURSOR(object)->orientation);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
示例#4
0
static void
cursor_paint(HosOrnament *self, HosCanvas *canvas)
{

  g_return_if_fail(HOS_IS_CURSOR(self));
  g_return_if_fail(HOS_IS_CANVAS(canvas));
  g_return_if_fail(GTK_WIDGET_DRAWABLE(canvas));

  HosCursor *cursor = HOS_CURSOR(self);
  GtkWidget *widget = GTK_WIDGET(canvas);
  GdkGC *gc = canvas->gc;

  gdouble pos = cursor_get_position(cursor);

  {
    GdkColor color = {0, 0xFFFF, 0xFFFF, 0xFFFF};
    gdk_gc_set_rgb_fg_color(gc, &color);
  }
  gdk_gc_set_line_attributes(gc,
			     1, /* width */
			     GDK_LINE_SOLID,
			     GDK_CAP_BUTT,
			     GDK_JOIN_MITER);

  if (cursor->orientation == HOS_VERTICAL)
    {
      canvas_world2view(canvas, &pos, NULL);
      gdk_draw_line(widget->window,
		    gc, pos, 0, pos, 1000000);
    }
  else
    {
      assert(cursor->orientation == HOS_HORIZONTAL);
      canvas_world2view(canvas, NULL, &pos);
      gdk_draw_line(widget->window,
		    gc, 0, pos, 1000000, pos);
    }
}