Beispiel #1
0
JNIEXPORT void JNICALL Java_net_hackcasual_freeciv_NativeHarness_init
  (JNIEnv *je, jobject o,  jint w, jint h) {
	civ_lock();
	width = w;
	height = h;
	android_width = w;
	android_height = h;

	  lastTouchX = w / 2;
	  lastTouchY = h / 2;
	  draw_city_productions = TRUE;
	  smooth_move_unit_msec = 200;
	  smooth_center_slide_msec = 100;
	  auto_center_on_combat = TRUE;

	if (!bufferData)
		bufferData = fc_malloc(BUFFER_SIZE);


    if (!displayCanvas || displayCanvas->width != w || displayCanvas->height != h) {
    	displayCanvas = fc_malloc(sizeof(struct sprite));
    	displayCanvas->width = w;
    	displayCanvas->height = h;
    	displayCanvas->data = bufferData;
    }
    LOGI("Setting display size: %dx%d", android_width, android_height);
    map_canvas_resized(w, h);
    civ_unlock();
}
Beispiel #2
0
/**************************************************************************
  Update on canvas widget size change
**************************************************************************/
gboolean map_canvas_configure(GtkWidget *w, GdkEventConfigure *ev,
                              gpointer data)
{
  map_canvas_resized(ev->width, ev->height);

  return TRUE;
}
Beispiel #3
0
static PyObject* python_map_canvas_resized(PyObject* self, PyObject* args) {
	int arg_width;
	int arg_height;
	if(PyArg_ParseTuple(args, "ii", &arg_width, &arg_height) == 0) return NULL;


	bool retval = map_canvas_resized(arg_width, arg_height);
	return Py_BuildValue("i", (int)retval);
}
Beispiel #4
0
/**************************************************************************
...
**************************************************************************/
void map_canvas_expose(Widget w, XEvent *event, Region exposed, 
		       void *client_data)
{
  Dimension width, height;
  bool map_resized;

  XtVaGetValues(w, XtNwidth, &width, XtNheight, &height, NULL);

  map_resized = map_canvas_resized(width, height);

  if (!can_client_change_view()) {
    if (!intro_gfx_sprite) {
      load_intro_gfx();
    }
    if (height != scaled_intro_pixmap_height
        || width != scaled_intro_pixmap_width) {
      if (scaled_intro_pixmap) {
	XFreePixmap(display, scaled_intro_pixmap);
      }

      scaled_intro_pixmap=x_scale_pixmap(intro_gfx_sprite->pixmap,
					 intro_gfx_sprite->width,
					 intro_gfx_sprite->height, 
					 width, height, root_window);
      scaled_intro_pixmap_width=width;
      scaled_intro_pixmap_height=height;
    }

    if(scaled_intro_pixmap)
       XCopyArea(display, scaled_intro_pixmap, XtWindow(map_canvas),
		 civ_gc,
		 event->xexpose.x, event->xexpose.y,
		 event->xexpose.width, event->xexpose.height,
		 event->xexpose.x, event->xexpose.y);
    return;
  }
  if(scaled_intro_pixmap) {
    XFreePixmap(display, scaled_intro_pixmap);
    scaled_intro_pixmap=0; scaled_intro_pixmap_height=0;
  }

  if (map_exists() && !map_resized) {
    /* First we mark the area to be updated as dirty.  Then we unqueue
     * any pending updates, to make sure only the most up-to-date data
     * is written (otherwise drawing bugs happen when old data is copied
     * to screen).  Then we draw all changed areas to the screen. */
    unqueue_mapview_updates(FALSE);
    XCopyArea(display, mapview.store->pixmap, XtWindow(map_canvas),
	      civ_gc,
	      event->xexpose.x, event->xexpose.y,
	      event->xexpose.width, event->xexpose.height,
	      event->xexpose.x, event->xexpose.y);
  }
  refresh_overview_canvas();
}
Beispiel #5
0
/****************************************************************************
  Really resize the main window.
****************************************************************************/
static void real_resize_window_callback(void *data)
{
    struct widget *widget;
    Uint32 flags = Main.screen->flags;

    if (gui_sdl_fullscreen) {
        flags |= SDL_FULLSCREEN;
    } else {
        flags &= ~SDL_FULLSCREEN;
    }
    set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, flags);

    if (C_S_RUNNING == client_state()) {
        /* Move units window to botton-right corner. */
        set_new_unitinfo_window_pos();
        /* Move minimap window to botton-left corner. */
        set_new_minimap_window_pos();

        /* Move cooling/warming icons to botton-right corner. */
        widget = get_widget_pointer_form_main_list(ID_WARMING_ICON);
        widget_set_position(widget, (Main.screen->w - adj_size(10)
                                     - (widget->size.w * 2)), widget->size.y);

        widget = get_widget_pointer_form_main_list(ID_COOLING_ICON);
        widget_set_position(widget, (Main.screen->w - adj_size(10)
                                     - widget->size.w), widget->size.y);

        map_canvas_resized(Main.screen->w, Main.screen->h);
        update_info_label();
        update_unit_info_label(get_units_in_focus());
        center_on_something();      /* With redrawing full map. */
        update_order_widgets();
    } else {
        draw_intro_gfx();
        dirty_all();
    }
    flush_all();
}