Exemplo n.º 1
0
// FIXME(ibadawi): Enforce minimum size for a window
void window_resize(struct window *window, int dw, int dh) {
  if (!window->parent) {
    return;
  }

  size_t *point = &window->parent->split.point;

  if (dw) {
    if (window->parent->split_type == WINDOW_SPLIT_VERTICAL) {
      if (window == window->parent->split.first) {
        *point = (size_t)((int)*point + dw);
      } else {
        assert(window == window->parent->split.second);
        *point = (size_t)((int)*point - dw);
      }
    } else {
      assert(window->parent->split_type == WINDOW_SPLIT_HORIZONTAL);
      struct window *parent = window->parent;
      while (parent && parent->split_type != WINDOW_SPLIT_VERTICAL) {
        window = parent;
        parent = parent->parent;
      }
      if (parent) {
        assert(parent->split_type == WINDOW_SPLIT_VERTICAL);
        window_resize(window, dw, 0);
      }
    }
  }

  if (dh) {
    if (window->parent->split_type == WINDOW_SPLIT_HORIZONTAL) {
      if (window == window->parent->split.first) {
        *point = (size_t)((int)*point + dh);
      } else {
        assert(window == window->parent->split.second);
        *point = (size_t)((int)*point - dh);
      }
    } else {
      assert(window->parent->split_type == WINDOW_SPLIT_VERTICAL);
      struct window *parent = window->parent;
      while (parent && parent->split_type != WINDOW_SPLIT_HORIZONTAL) {
        window = parent;
        parent = parent->parent;
      }
      if (parent) {
        assert(parent->split_type == WINDOW_SPLIT_HORIZONTAL);
        window_resize(window, 0, dh);
      }
    }
  }
}
Exemplo n.º 2
0
void level_change_level(struct game* game, struct player* player, struct map* map) {
	assert(game);
	assert(player);
	assert(map);

	struct level* level = game_get_curr_level(game);
	struct list* bList = map_get_bombs(map);

	while(bList != NULL) {
		bList = list_cut_head(bList);
		player_inc_nb_bomb(player);
	}

	level_free(level);
	level = game_next_lvl(game);

	if(level == NULL) {
		printf("Level null, maybe there is no more level ?\n");
		return;
	}
	else {
		//printf("Next level\n");
	}
	players_from_map(game, level->maps[level->cur_map]);
	window_resize(map_get_width(level_get_curr_map(level)) * SIZE_BLOC, map_get_height(level_get_curr_map(level)) * SIZE_BLOC + BANNER_HEIGHT + LINE_HEIGHT);
}
static gboolean
gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
{
  GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
  gint ret = graphics_get_display_size (0, &window_egl->dp_width,
      &window_egl->dp_height);
  if (ret < 0) {
    GST_ERROR ("Can't open display");
    return FALSE;
  }
  GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
      window_egl->dp_height);

  window_egl->native.width = 0;
  window_egl->native.height = 0;
  window_egl->display = vc_dispmanx_display_open (0);
  window_egl->native.element = 0;

  window_egl->main_context = g_main_context_new ();
  window_egl->loop = g_main_loop_new (window_egl->main_context, FALSE);

  window_resize (window_egl, 16, 16);

  return TRUE;
}
Exemplo n.º 4
0
void level_change_map(struct game* game, struct player* player, struct map* map, unsigned char num) {
	struct level* level = game_get_curr_level(game);
	struct list* bList = map_get_bombs(map);

	assert(game);
	assert(player);
	assert(map);

	if(num < level->nb_maps) {

		while(bList != NULL) {
			map_set_cell_type(map, list_get_x(bList), list_get_y(bList), CELL_EMPTY);
			bList = list_cut_head(bList);
			player_inc_nb_bomb(player);
		}
		map_set_bombs(map, NULL);
		player_reset_way_mov(player);
		level->cur_map = num;
		//printf("Next map\n");
		int x = player_get_x(player);
		int y = player_get_y(player);
		players_from_map(game, level->maps[level->cur_map]);
		if(player_get_x(player) == 0 && player_get_y(player) == 0) {
			player_set_x(player, x);
			player_set_x(player, y);
		}
		map_load_monsters(level->maps[level->cur_map], game);
		window_resize(map_get_width(level_get_curr_map(level)) * SIZE_BLOC, map_get_height(level_get_curr_map(level)) * SIZE_BLOC + BANNER_HEIGHT + LINE_HEIGHT);
	}
}
Exemplo n.º 5
0
static gboolean
idle_resize (GtkSourceCompletionInfo *info)
{
	info->priv->idle_resize = 0;
	
	window_resize (info);
	return FALSE;
}
Exemplo n.º 6
0
void
gtk_source_completion_info_process_resize (GtkSourceCompletionInfo *info)
{
	g_return_if_fail (GTK_IS_SOURCE_COMPLETION_INFO (info));
	
	if (info->priv->idle_resize != 0)
		window_resize (info);
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
	if (argc < 2) {
		printf("Compositor server not specified.\n");
		return 1;
	}
	
	list_initialize(&led_devs);
	int rc = loc_register_cat_change_cb(loc_callback);
	if (rc != EOK) {
		printf("Unable to register callback for device discovery.\n");
		return 1;
	}
	
	led_timer = fibril_timer_create(NULL);
	if (!led_timer) {
		printf("Unable to create LED timer.\n");
		return 1;
	}
	
	frame_timer = fibril_timer_create(NULL);
	if (!frame_timer) {
		printf("Unable to create frame timer.\n");
		return 1;
	}
	
	if (!decode_frames())
		return 1;
	
	winreg = argv[1];
	window_t *main_window = window_open(argv[1], NULL,
	    WINDOW_MAIN | WINDOW_DECORATED, "barber");
	if (!main_window) {
		printf("Cannot open main window.\n");
		return 1;
	}
	
	frame_canvas = create_canvas(window_root(main_window), NULL,
	    FRAME_WIDTH, FRAME_HEIGHT, frames[frame]);
	
	if (!frame_canvas) {
		window_close(main_window);
		printf("Cannot create widgets.\n");
		return 1;
	}
	
	window_resize(main_window, 0, 0, FRAME_WIDTH + 8, FRAME_HEIGHT + 28,
	    WINDOW_PLACEMENT_RIGHT | WINDOW_PLACEMENT_BOTTOM);
	window_exec(main_window);
	
	plan_led_timer();
	plan_frame_timer(0);
	
	task_retval(0);
	async_manager();
	
	return 0;
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
	if (argc >= 2) {
		window_t *main_window = window_open(argv[1], NULL,
		    WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vdemo");
		if (!main_window) {
			printf("Cannot open main window.\n");
			return 1;
		}

		pixel_t grd_bg = PIXEL(255, 240, 240, 240);
		
		pixel_t btn_bg = PIXEL(255, 240, 240, 240);
		pixel_t btn_fg = PIXEL(255, 186, 186, 186);
		pixel_t btn_text = PIXEL(255, 0, 0, 0);
		
		pixel_t lbl_bg = PIXEL(255, 240, 240, 240);
		pixel_t lbl_text = PIXEL(255, 0, 0, 0);

		my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16,
		    lbl_bg, lbl_text);
		button_t *btn_confirm = create_button(NULL, NULL, "Confirm", 16,
		    btn_bg, btn_fg, btn_text);
		button_t *btn_cancel = create_button(NULL, NULL, "Cancel", 16,
		    btn_bg, btn_fg, btn_text);
		grid_t *grid = create_grid(window_root(main_window), NULL, 2, 2,
		    grd_bg);
		if (!lbl_action || !btn_confirm || !btn_cancel || !grid) {
			window_close(main_window);
			printf("Cannot create widgets.\n");
			return 1;
		}

		sig_connect(
		    &btn_confirm->clicked,
		    &lbl_action->label.widget,
		    lbl_action->confirm);
		sig_connect(
		    &btn_cancel->clicked,
		    &lbl_action->label.widget,
		    lbl_action->cancel);

		grid->add(grid, &lbl_action->label.widget, 0, 0, 2, 1);
		grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1);
		grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1);
		window_resize(main_window, 0, 0, 200, 76,
		    WINDOW_PLACEMENT_CENTER);

		window_exec(main_window);
		task_retval(0);
		async_manager();
		return 1;
	} else {
		printf("Compositor server not specified.\n");
		return 1;
	}
}
gboolean
gst_gl_window_dispmanx_egl_create_window (GstGLWindowDispmanxEGL * window_egl)
{
  window_egl->native.width = 0;
  window_egl->native.height = 0;
  window_egl->display = vc_dispmanx_display_open (0);
  window_resize (window_egl, 16, 16, FALSE);
  return TRUE;
}
Exemplo n.º 10
0
void update_motion_recorder(void)
{
	xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, root), NULL);

	if (geo != NULL) {
		window_resize(motion_recorder, geo->width, geo->height);
	}

	free(geo);
}
static void
gst_gl_window_dispmanx_egl_show (GstGLWindow * window)
{
  GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);

  if (!window_egl->visible) {
    window_resize (window_egl, window_egl->preferred_width,
        window_egl->preferred_height, TRUE);
    window_egl->visible = TRUE;
  }
}
static void
handle_configure (void *data, struct wl_shell_surface *shell_surface,
    uint32_t edges, int32_t width, int32_t height)
{
  GstGLWindowWaylandEGL *window_egl = data;

  GST_DEBUG ("configure event on surface %p, %ix%i", shell_surface, width,
      height);

  window_resize (window_egl, width, height);
}
Exemplo n.º 13
0
/*
 * Rearrange left and right child of a given pair, based on method and sized
 * already set in the (as usually) right window.
 */
void window_rearrange(winid_t pair)
{
   SDL_Rect left_area, right_area;
   window_calc_sizes(pair, &left_area, &right_area);

   // Let the window resize first, which size has been reduced, so that it can
   // copy from the old area before the now larger window will overwrite it.
   int or = pair->right->method & winmethod_DirMask;
   if(((or == winmethod_Above || or == winmethod_Below) &&
       left_area.h < pair->left->area.h) ||
      ((or == winmethod_Left || or == winmethod_Right) &&
       left_area.w < pair->left->area.w)) {
      window_resize(pair->left, &left_area);
      window_resize(pair->right, &right_area);
   } else {
      window_resize(pair->right, &right_area);
      window_resize(pair->left, &left_area);
   }

   window_draw_border(pair);
}
static gboolean
gst_gl_window_dispmanx_egl_set_render_rectangle (GstGLWindow * window,
    gint x, gint y, gint width, gint height)
{
  GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
  window_egl->render_rect.x = x;
  window_egl->render_rect.y = y;
  window_egl->render_rect.w = width;
  window_egl->render_rect.h = height;

  window_resize (window_egl, window_egl->render_rect.w,
      window_egl->render_rect.h, TRUE);
  return TRUE;
}
Exemplo n.º 15
0
static void input_window_resize_continue(rct_window *w, sint32 x, sint32 y)
{
	if (y < (sint32)gScreenHeight - 2) {
		sint32 dx, dy, targetWidth, targetHeight;
		dx = x - gInputDragLastX;
		dy = y - gInputDragLastY;
		targetWidth = _originalWindowWidth + dx;
		targetHeight = _originalWindowHeight + dy;

		window_resize(
			w,
			targetWidth - w->width,
			targetHeight - w->height
			);
	}
}
Exemplo n.º 16
0
static void input_window_resize_continue(rct_window *w, int x, int y)
{
	int dx, dy, targetWidth, targetHeight;

	if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) {
		dx = x - gInputDragLastX;
		dy = y - gInputDragLastY;
		targetWidth = _originalWindowWidth + dx;
		targetHeight = _originalWindowHeight + dy;

		window_resize(
			w,
			targetWidth - w->width,
			targetHeight - w->height
			);
	}
}
static void
_set_render_rectangle (gpointer data)
{
  struct SetRenderRectangle *render = data;

  GST_LOG_OBJECT (render->window_egl, "setting render rectangle %i,%i+%ix%i",
      render->rect.x, render->rect.y, render->rect.w, render->rect.h);

  if (render->window_egl->window.subsurface) {
    wl_subsurface_set_sync (render->window_egl->window.subsurface);
    wl_subsurface_set_position (render->window_egl->window.subsurface,
        render->rect.x, render->rect.y);
    render->window_egl->window.window_x = render->rect.x;
    render->window_egl->window.window_y = render->rect.y;
  }

  window_resize (render->window_egl, render->rect.w, render->rect.h);
}
Exemplo n.º 18
0
struct level* level_get_level(struct game* game, int n_lvl, int n_map) {
	

	struct level* level = malloc(sizeof(*level));
	int map_count = 0;
	int nb_players = game_get_nb_player(game);

	if(nb_players >= 2) {
		level->nb_maps = sprite_get_nb_map_multi();
		level->cur_map = n_map;
		level->maps = malloc(sizeof(*level->maps) * level->nb_maps);
		for(int i = 0; i < level->nb_maps; i++)
			level->maps[i] = file_load_map_multi(i, nb_players);
	}
	else {
		for(int i = 0; i < 8; i++) {
			if(file_map_exist(n_lvl, i))
				map_count++;
			else
				i = 8;
		}

		if(map_count == 0)
			return NULL;

		level->nb_maps = map_count;
		level->cur_map = n_map;

		level->maps = malloc(sizeof(*level->maps) * level->nb_maps);

		for(int i = 0; i < level->nb_maps; i++) {
			level->maps[i] = file_load_map(n_lvl, i);
		}

		map_load_monsters(level->maps[0], game);
	} // end else

	window_resize(map_get_width(level_get_curr_map(level)) * SIZE_BLOC, map_get_height(level_get_curr_map(level)) * SIZE_BLOC + BANNER_HEIGHT + LINE_HEIGHT);

	return level;
}
static void
draw_cb (gpointer data)
{
  GstGLWindowDispmanxEGL *window_egl = data;
  GstGLWindow *window = GST_GL_WINDOW (window_egl);
  GstGLContext *context = gst_gl_window_get_context (window);
  GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);

  if (window_egl->native.width != window_egl->preferred_width
      || window_egl->native.height != window_egl->preferred_height) {
    GST_DEBUG ("dimensions don't match, attempting resize");
    window_resize (window_egl, window_egl->preferred_width,
        window_egl->preferred_height);
  }

  if (window->draw)
    window->draw (window->draw_data);

  context_class->swap_buffers (context);

  gst_object_unref (context);
}
Exemplo n.º 20
0
int run(
    int width,
    int height,
    const std::string& caption,
    const std::function<void(GLFWwindow* window)>& func)
{
    if (!glfwInit()) {
        std::cerr << "Cannot initialize glfw." << std::endl;
        return -1;
    }

    auto window = create_window(width, height, caption);

    if (!window) {
        std::cerr << "Cannot create window." << std::endl;
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);
    glfwSwapInterval(0);

    if (!gladLoadGL()) {
        std::cerr << "Cannot load glad extensions." << std::endl;
        glfwTerminate();
        return -1;
    }

    std::cerr << "Loaded OpenGL "
        << GLVersion.major << "."
        << GLVersion.minor << " profile."
        << std::endl;

    window_context_t* context = new window_context_t();
    glfwSetWindowUserPointer(window, context);
    glfwSetWindowSizeCallback(window, window_resize);
    window_resize(window, width, height);
    context->program_id = create_program();
    context->sampler_location = glGetUniformLocation(context->program_id, "sampler");
    context->scale_location = glGetUniformLocation(context->program_id, "scale");

    glGenVertexArrays(1, &context->varray_id);
    glBindVertexArray(context->varray_id);

    context->buffer_id = create_fullscreen_quad();

    auto& io = ImGui::GetIO();
    io.IniFilename = nullptr;
    ImGui_ImplGlfwGL3_Init(window, true);

    func(window);

    if (context->texture_created) {
        glDeleteTextures(1, &context->texture_id);
    }

    glDeleteVertexArrays(1, &context->varray_id);

    delete context;

    glfwTerminate();

    return 0;
}
Exemplo n.º 21
0
DECLARE_TEST( window, sizemove )
{
	window_t* window;
#if FOUNDATION_PLATFORM_MACOSX
	window = window_allocate_from_nswindow( delegate_nswindow() );
#elif FOUNDATION_PLATFORM_IOS
	window = window_allocate_from_uiwindow( delegate_uiwindow() );
#endif
	
	EXPECT_NE( window, 0 );
	EXPECT_TRUE( window_is_open( window ) );

	thread_sleep( 1000 );
	
#if FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID
	EXPECT_TRUE( window_is_maximized( window ) );
#else
	EXPECT_FALSE( window_is_maximized( window ) );
#endif
	
	EXPECT_TRUE( window_is_visible( window ) );
	EXPECT_TRUE( window_has_focus( window ) );
	
	window_maximize( window );
	thread_sleep( 1000 );
	EXPECT_TRUE( window_is_maximized( window ) );
	EXPECT_TRUE( window_has_focus( window ) );

#if !FOUNDATION_PLATFORM_IOS && !FOUNDATION_PLATFORM_ANDROID
	window_restore( window );
	thread_sleep( 1000 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_TRUE( window_has_focus( window ) );
#endif
	
	window_maximize( window );
	thread_sleep( 1000 );
	EXPECT_TRUE( window_is_maximized( window ) );
		
#if !FOUNDATION_PLATFORM_IOS && !FOUNDATION_PLATFORM_ANDROID
	window_resize( window, 150, 100 );
	thread_sleep( 1000 );
	EXPECT_EQ( window_width( window ), 150 );
	EXPECT_EQ( window_height( window ), 100 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_TRUE( window_has_focus( window ) );
	
	window_move( window, 10, 20 );
	thread_sleep( 1000 );
	EXPECT_EQ( window_position_x( window ), 10 );
	EXPECT_EQ( window_position_y( window ), 20 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_TRUE( window_has_focus( window ) );
	
	window_minimize( window );
	thread_sleep( 1000 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_FALSE( window_has_focus( window ) );

	window_restore( window );
	thread_sleep( 1000 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_FALSE( window_is_minimized( window ) );
	EXPECT_TRUE( window_has_focus( window ) );
	
	window_minimize( window );
	thread_sleep( 1000 );
	EXPECT_FALSE( window_is_maximized( window ) );
	EXPECT_TRUE( window_is_minimized( window ) );
#endif
		
	window_deallocate( window );
	window = 0;
	
	EXPECT_FALSE( window_is_open( window ) );
	
	return 0;
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
char buffer[30];
struct timeval tv;
struct tm result;
window_t *main_window = window_open(argv[1], true, true," ",0,720);
	if (!main_window) {
	printf("Cannot open main window.\n");
		return 1;
	}

	time_t curtime;
	gettimeofday(&tv, NULL); 
	curtime=tv.tv_sec;
	time_utc2tm(curtime,&result);
	strftime(buffer,30,"%T %m-%d-%Y",&result);

	pixel_t grd_bg = PIXEL(255, 25, 25, 112);
	
	pixel_t lbl_bg = PIXEL(255, 25, 25, 112);//(255, 240, 240, 240);
	pixel_t lbl_fg = PIXEL(255, 255, 255, 255);

	my_label_t *stime= create_my_label(NULL,buffer, 16, lbl_bg, lbl_fg);

	grid_t *grid = create_grid(window_root(main_window),1, 10, grd_bg);
	grid->add(grid, &stime->label.widget, 0, 7, 1, 2);
	window_resize(main_window,1024,60);
	window_exec(main_window);

	while(1){
		gettimeofday(&tv, NULL); 
		curtime=tv.tv_sec;
		time_utc2tm(curtime,&result);

//Converting month to integer		
		char month[5];
		strftime(month,5,"%m",&result);
		char *mon;
		mon=month;
		int value=0;
		value=toInteger1(mon);

		switch(value){
case 0:
			strftime(buffer,30,"%T Jan-%d, %Y",&result);		
			break;
case 1:
			strftime(buffer,30,"%T Feb-%d, %Y",&result);		
			break;
case 2:
			strftime(buffer,30,"%T Mar-%d, %Y",&result);		
			break;
case 3:
			strftime(buffer,30,"%T Apr-%d, %Y",&result);		
			break;
case 4:
			strftime(buffer,30,"%T May-%d, %Y",&result);		
			break;
case 5:
			strftime(buffer,30,"%T Jun-%d, %Y",&result);		
			break;
case 6:
			strftime(buffer,30,"%T Jul-%d, %Y",&result);		
			break;
case 7:
			strftime(buffer,30,"%T Aug-%d, %Y",&result);		
			break;
case 8:
			strftime(buffer,30,"%T Sep-%d, %Y",&result);		
			break;
case 9:
			strftime(buffer,30,"%T Oct-%d, %Y",&result);		
			break;
case 10:
			strftime(buffer,30,"%T Nov-%d, %Y",&result);		
			break;
case 11:
			strftime(buffer,30,"%T Dec-%d, %Y",&result);		
			break;
		}	
		stime->label.rewrite(&stime->label.widget, (void *)buffer);
	}

	task_retval(0);
	async_manager();

return 0;
}
Exemplo n.º 23
0
int display_browser_handler(window_info *win)
{
   //title bar
   //draw_menu_title_bar(browser_menu_x,browser_menu_y-16,browser_menu_x_len);
   // window drawing
   glEnable(GL_BLEND);
   glBlendFunc(GL_ONE,GL_SRC_ALPHA);
   glDisable(GL_TEXTURE_2D);
  
   glDisable(GL_BLEND);
   glColor3f(0.77f,0.57f,0.39f);
   glBegin(GL_LINES);

		//scroll bar
   if(!mc){
	glVertex3i(win->len_x-20,20,0);
	glVertex3i(win->len_x-20,400,0);
   }
   if(cd!=-1){
	glVertex3i(win->len_x-15,30,0);
	glVertex3i(win->len_x-10,25,0);
	glVertex3i(win->len_x-10,25,0);
	glVertex3i(win->len_x-5,30,0);
	glVertex3i(win->len_x-15,385,0);
	glVertex3i(win->len_x-10,390,0);
	glVertex3i(win->len_x-10,390,0);
	glVertex3i(win->len_x-5,385,0);
	//separators
	glVertex3i(0+200,0,0);
	glVertex3i(0+200,0+400,0);
	glVertex3i(0,0+200,0);
	glVertex3i(0+400,0+200,0);
   }

   glEnd();
   glEnable(GL_TEXTURE_2D);
   // The X
	
   if(!mc){
	draw_string(win->len_x-16,160,(unsigned char *)"B",1);
	draw_string(win->len_x-16,180,(unsigned char *)"A",1);
	draw_string(win->len_x-16,200,(unsigned char *)"C",1);
	draw_string(win->len_x-16,220,(unsigned char *)"K",1);
   }

   draw_string(0+win->len_x-16,0+2,(unsigned char *)"X",1);

   if(cd==-1){ //display dir select menu
	   int i,x=0,y=2;
	   if(mc==1){
			for(i=0;i<=cc;i++){
				draw_string(x+2,0+y,(unsigned char *)Cat[i].Name,1);
				y+=18;
				if(y>=398){
					x=210;
					y=2;
				}
			}	
	   }else{
			for(i=0;i<Cat[ccat].ns;i++){
				draw_string(x+2,0+y,(unsigned char *)Cat[ccat].Sub[i]->DirName,1);
				y+=18;
				if(y>=398){
					x=210;
					y=2;
				}
			}
	   }
   }else{ // display specified dir
		int i=cp,valid_object=0;
		float tz=zoom_level;
		char fn[256];
		
		// Prepare to render
		Leave2DMode();
		glEnable(GL_CULL_FACE);
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		if(have_multitexture && clouds_shadows){
			//bind the detail texture
			glActiveTextureARB(GL_TEXTURE1_ARB);
			glEnable(GL_TEXTURE_2D);
#ifdef	NEW_TEXTURES
			bind_texture_unbuffered(ground_detail_text);
#else	/* NEW_TEXTURES */
			glBindTexture(GL_TEXTURE_2D,  texture_cache[ground_detail_text].texture_id);
#endif	/* NEW_TEXTURES */
			glActiveTextureARB(GL_TEXTURE0_ARB);
			glEnable(GL_TEXTURE_2D);
		}

		// Now we draw the 4 objects
		zoom_level=3.0;
		window_resize();
		glRotatef(-60, 1.0f, 0.0f, 0.0f);
		glRotatef(0, 0.0f, 0.0f, 1.0f);
		glRotatef(45, 0.0f, 0.0f, 1.0f);

		glViewport(win->pos_x,window_height-win->pos_y-150,200,150);
		glClearStencil(0);
		glClear (GL_DEPTH_BUFFER_BIT);
#ifdef LINUX
		strcpy(fn,exec_path);
#else
		//Fedora: don't ask me why, if you use exec_path, e3d files are not found
		strcpy(fn,"."/*exec_path*/);
#endif
		strcat(fn,Dir[cd].Files[i]);
		valid_object=setobject(0,fn,Dir[cd].xrot[i],Dir[cd].yrot[i],Dir[cd].zrot[i]);
		if(valid_object){
			glPushMatrix();
			glScalef(Dir[cd].size[i],Dir[cd].size[i],Dir[cd].size[i]);
			draw_3d_object(&o3d[0]);
			glPopMatrix();
		}
		

		if(i+1<Dir[cd].nf){
			glViewport(win->pos_x+200,window_height-win->pos_y-150,200,150);	
			glClearStencil(0);
			glClear (GL_DEPTH_BUFFER_BIT);
#ifdef LINUX
			strcpy(fn,exec_path);
#else
			//Fedora: don't ask me why, if you use exec_path, e3d files are not found
			strcpy(fn,"."/*exec_path*/);
#endif
			strcat(fn,Dir[cd].Files[i+1]);
			valid_object=setobject(1,fn,Dir[cd].xrot[i+1],Dir[cd].yrot[i+1],Dir[cd].zrot[i+1]);
			if(valid_object){
				glPushMatrix();
				glScalef(Dir[cd].size[i+1],Dir[cd].size[i+1],Dir[cd].size[i+1]);
				draw_3d_object(&o3d[1]);
				glPopMatrix();
			}
		}

		if(i+2<Dir[cd].nf){
			glViewport(win->pos_x,window_height-win->pos_y-350,200,150);	
			glClearStencil(0);
			glClear (GL_DEPTH_BUFFER_BIT);
#ifdef LINUX
			strcpy(fn,exec_path);
#else
			//Fedora: don't ask me why, if you use exec_path, e3d files are not found
			strcpy(fn,"."/*exec_path*/);
#endif
			strcat(fn,Dir[cd].Files[i+2]);
			valid_object=setobject(2,fn,Dir[cd].xrot[i+2],Dir[cd].yrot[i+2],Dir[cd].zrot[i+2]);
			if(valid_object){
				glPushMatrix();
				glScalef(Dir[cd].size[i+2],Dir[cd].size[i+2],Dir[cd].size[i+2]);
				draw_3d_object(&o3d[2]);
				glPopMatrix();
			}
		}

		if(i+3<Dir[cd].nf){
			glViewport(win->pos_x+200,window_height-win->pos_y-350,200,150);	
			glClearStencil(0);
			glClear (GL_DEPTH_BUFFER_BIT);
#ifdef LINUX
			strcpy(fn,exec_path);
#else
			//Fedora: don't ask me why, if you use exec_path, e3d files are not found
			strcpy(fn,"."/*exec_path*/);
#endif
			strcat(fn,Dir[cd].Files[i+3]);
			valid_object=setobject(3,fn,Dir[cd].xrot[i+3],Dir[cd].yrot[i+3],Dir[cd].zrot[i+3]);
			if(valid_object){
				glPushMatrix();
				glScalef(Dir[cd].size[i+3],Dir[cd].size[i+3],Dir[cd].size[i+3]);
				draw_3d_object(&o3d[3]);
				glPopMatrix();
			}
		}

		zoom_level=tz;
		window_resize();
		// Back to normal
		glViewport(0,0,window_width,window_height);
		glDisable(GL_CULL_FACE);
		glDisableClientState(GL_VERTEX_ARRAY);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		if(have_multitexture && clouds_shadows)
			{
				//disable the second texture unit
				glActiveTextureARB(GL_TEXTURE1_ARB);
				glDisable(GL_TEXTURE_2D);
				glActiveTextureARB(GL_TEXTURE0_ARB);
			}
		Enter2DMode();
		CHECK_GL_ERRORS();

		// Object names
		draw_string(win->pos_x+2,win->pos_y+200-18,(unsigned char *)Dir[cd].Names[i],1);
		draw_string(win->pos_x+2,win->pos_y+400-18,(unsigned char *)Dir[cd].Names[i+2],1);
		draw_string(win->pos_x+202,win->pos_y+200-18,(unsigned char *)Dir[cd].Names[i+1],1);
		draw_string(win->pos_x+202,win->pos_y+400-18,(unsigned char *)Dir[cd].Names[i+3],1);

   }
	return 1;
}
Exemplo n.º 24
0
void init_stuff()
{
	int i;
	int seed;

	chdir(DATA_DIR);
	
#ifndef WINDOWS
	setlocale(LC_NUMERIC,"en_US");
#endif
	init_translatables();

	//create_error_mutex();
	init_globals();
	init_crc_tables();
	init_zip_archives();
	cache_system_init(MAX_CACHE_SYSTEM);
	init_texture_cache();

	init_vars();
	
	read_config();

	file_check_datadir();

#ifdef LOAD_XML
	//Well, the current version of the map editor doesn't support having a datadir - will add that later ;-)
	load_translatables();
#endif

#ifdef LINUX
#ifdef GTK2
	init_filters();
#else
	file_selector = create_fileselection();
#endif
#endif	//LINUX

	init_gl();

	window_resize();
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
//	glDepthFunc(GL_LEQUAL);
    glEnable(GL_TEXTURE_2D);
	glShadeModel(GL_SMOOTH);
	glFrontFace(GL_CCW);
	glCullFace(GL_BACK);
	glEnable(GL_NORMALIZE);
	glClearColor( 0.0, 0.0, 0.0, 0.0 );
	glClearStencil(0);

	seed = time (NULL);
  	srand (seed);

	init_texture_cache();
	init_particles ();
	init_e3d_cache();
	init_2d_obj_cache();

	for(i=0; i<256; i++)
        tile_list[i]=0;

	for (i = 0; i < MAX_LIGHTS; i++)
		lights_list[i] = NULL;

	new_map(256,256);
	load_all_tiles();

	//lights setup
	build_global_light_table();
	build_sun_pos_table();
	reset_material();
	init_lights();
	//disable_local_lights();
	//clear_error_log();

	// Setup the new eye candy system
#ifdef	EYE_CANDY
	ec_init();
#endif	//EYE_CANDY

	init_gl_extensions();

	if(have_multitexture)
#ifdef	NEW_TEXTURES
		ground_detail_text = load_texture_cached("./textures/ground_detail.bmp", tt_mesh);
#else	/* NEW_TEXTURES */
		ground_detail_text = load_texture_cache ("./textures/ground_detail.bmp",255);
#endif	/* NEW_TEXTURES */

	//load the fonts texture
	init_fonts();
#ifdef	NEW_TEXTURES
	icons_text=load_texture_cached("./textures/gamebuttons.bmp", tt_gui);
	buttons_text=load_texture_cached("./textures/buttons.bmp", tt_gui);
#else	/* NEW_TEXTURES */
	icons_text=load_texture_cache("./textures/gamebuttons.bmp",0);
	buttons_text=load_texture_cache("./textures/buttons.bmp",0);
#endif	/* NEW_TEXTURES */
	//get the application home dir

	have_multitexture=0;//debug only

#ifndef LINUX
	GetCurrentDirectory(sizeof(exec_path),exec_path);
#else
	exec_path[0]='.';exec_path[1]='/';exec_path[2]=0;
#endif
	init_browser();

    if(SDL_InitSubSystem(SDL_INIT_TIMER)<0)
    { 
        char str[120];
        snprintf(str, sizeof(str), "Couldn't initialize the timer: %s\n", SDL_GetError());
        log_error(__FILE__, __LINE__, str);
        SDL_Quit();
	    exit(1);
    }

	SDL_SetTimer (1000/(18*4), my_timer);

	SDL_EnableUNICODE(1);

    //we might want to do this later.

	// creating windows
	display_browser();
	toggle_window(browser_win);

	display_o3dow();
	toggle_window(o3dow_win);

	display_replace_window();
	toggle_window(replace_window_win);

	display_edit_window();
	toggle_window(edit_window_win);

	create_particles_window ();
}
Exemplo n.º 25
0
void
recalculate_sizes(void)
{
	struct session		*s;
	struct client		*c;
	struct window		*w;
	struct window_pane	*wp;
	u_int		 	 i, j, ssx, ssy, has, limit;
	int		 	 flag;

	for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
		s = ARRAY_ITEM(&sessions, i);
		if (s == NULL)
			continue;

		ssx = ssy = UINT_MAX;
		for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
			c = ARRAY_ITEM(&clients, j);
			if (c == NULL || c->flags & CLIENT_SUSPENDED)
				continue;
			if (c->session == s) {
				if (c->tty.sx < ssx)
					ssx = c->tty.sx;
				if (c->tty.sy < ssy)
					ssy = c->tty.sy;
			}
		}
		if (ssx == UINT_MAX || ssy == UINT_MAX) {
			s->flags |= SESSION_UNATTACHED;
			continue;
		}
		s->flags &= ~SESSION_UNATTACHED;

		if (options_get_number(&s->options, "status")) {
			if (ssy == 0)
				ssy = 1;
			else
				ssy--;
		}
		if (s->sx == ssx && s->sy == ssy)
			continue;

		log_debug(
		    "session size %u,%u (was %u,%u)", ssx, ssy, s->sx, s->sy);

		s->sx = ssx;
		s->sy = ssy;
	}

	for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
		w = ARRAY_ITEM(&windows, i);
		if (w == NULL)
			continue;
		flag = options_get_number(&w->options, "aggressive-resize");

		ssx = ssy = UINT_MAX;
		for (j = 0; j < ARRAY_LENGTH(&sessions); j++) {
			s = ARRAY_ITEM(&sessions, j);
			if (s == NULL || s->flags & SESSION_UNATTACHED)
				continue;
			if (flag)
				has = s->curw->window == w;
			else
				has = session_has(s, w);
			if (has) {
				if (s->sx < ssx)
					ssx = s->sx;
				if (s->sy < ssy)
					ssy = s->sy;
			}
		}
		if (ssx == UINT_MAX || ssy == UINT_MAX) {
			w->flags |= WINDOW_HIDDEN;
			continue;
		}
		w->flags &= ~WINDOW_HIDDEN;

		limit = options_get_number(&w->options, "force-width");
		if (limit != 0 && ssx > limit)
			ssx = limit;
		limit = options_get_number(&w->options, "force-height");
		if (limit != 0 && ssy > limit)
			ssy = limit;

		if (w->sx == ssx && w->sy == ssy)
			continue;

		log_debug(
		    "window size %u,%u (was %u,%u)", ssx, ssy, w->sx, w->sy);

		layout_resize(w, ssx, ssy);
		window_resize(w, ssx, ssy);

		/*
		 * If the current pane is now not visible, move to the next
		 * that is.
		 */
		wp = w->active;
		while (!window_pane_visible(w->active)) {
			w->active = TAILQ_PREV(w->active, window_panes, entry);
			if (w->active == NULL)
				w->active = TAILQ_LAST(&w->panes, window_panes);
			if (w->active == wp)
			       break;
		}

		server_redraw_window(w);
	}
}
Exemplo n.º 26
0
winid_t glk_window_open(winid_t split, glui32 method, glui32 size,
                        glui32 wintype, glui32 rock)
{
   winid_t win = (winid_t)nano_malloc(sizeof(struct glk_window_struct));
   nanoglk_log("glk_window_open(%p, %d, %d, %d, %d) => %p",
              split, method, size, wintype, rock, win);

   win->stream = nanoglk_stream_new(streamtype_Window, 0);
   win->stream->x.window = win;

   win->method = method;
   win->size = size;
   win->wintype = wintype;
   win->rock = rock;
   win->left = win->right = NULL;
   win->cur_styl = style_Normal;
   
   // Colors for styles. See comment at the beginning of this file.
   int i;
   switch(win->wintype) {
   case wintype_TextBuffer:
      for(i = 0; i < style_NUMSTYLES; i++) {
         win->fg[i] = next_buffer_fg[i];
         win->bg[i] = next_buffer_bg[i];
      }
      break;

   case wintype_TextGrid:
      for(i = 0; i < style_NUMSTYLES; i++) {
         win->fg[i] = next_grid_fg[i];
         win->bg[i] = next_grid_bg[i];
      }
      break;
   }

   winid_t pair;
   
   if(split == NULL) {
      // parent is NULL => new root window
      nano_failunless(root == NULL, "two root windows");

      win->parent = NULL;
      win->area.x = win->area.y = 0;
      win->area.w = nanoglk_surface->w;
      win->area.h = nanoglk_surface->h;

      root = win;

      pair = NULL; // no pair window created

      nano_trace("[glk_window_open] root %p: (%d, %d, %d x %d)",
                 win, win->area.x, win->area.y, win->area.w, win->area.h);
   } else {
      // Create a pair window. The old parent "split" becomes the left
      // child, the newly created becomes the right child. (See also
      // comment on these members in "nanoglk.h".)
      pair = (winid_t)nano_malloc(sizeof(struct glk_window_struct));
      pair->stream = NULL;
      pair->wintype = wintype_Pair;
      pair->rock = 0;
      pair->left = split;
      pair->right = win;
      pair->area = split->area;
      pair->method = split->method;
      pair->size = split->size;
      pair->parent = split->parent;

      // Rearrange tree: "pair" takes over the place of "split".
      if(pair->parent == NULL)
         root = pair;
      else {
         if(pair->parent->left == split)
            pair->parent->left = pair;
         else if(pair->parent->right == split)
            pair->parent->right = pair;
         else
            nano_fail("split not child of parent?");
      }

      split->parent = win->parent = pair;
      pair->left = split;
      pair->right = win;

      win->area = split->area;
      SDL_Rect split_area, win_area;
      window_calc_sizes(pair, &split_area, &win_area);
      window_resize(split, &split_area);
      win->area = win_area;

      window_draw_border(pair);

      nano_trace("split %p: (%d, %d, %d x %d)", split, split->area.x,
                split->area.y, split->area.w, split->area.h);
      nano_trace("new win %p: (%d, %d, %d x %d)", win, win->area.x,
                 win->area.y, win->area.w, win->area.h);
   }

   // Further initialization depending on the type.
   switch(win->wintype) {
   case wintype_TextBuffer:
      nanoglk_wintextbuffer_init(win);
      break;

   case wintype_TextGrid:
      nanoglk_wintextgrid_init(win);
      break;

   case wintype_Graphics:
      nanoglk_wingraphics_init(win);
      break;
   }

   if(pair)
      pair->disprock = nanoglk_call_regi_obj(pair, gidisp_Class_Window);

   win->stream->disprock
      = nanoglk_call_regi_obj(win->stream, gidisp_Class_Stream);
   win->disprock = nanoglk_call_regi_obj(win, gidisp_Class_Window);
   
   return win;
}
Exemplo n.º 27
0
void multi_display(struct game* game) {
	assert(game);
	struct map* map = NULL;
	int w, h;
	int* scores;

	switch(game_get_state(game)) {
	case PLAYING:
	case PAUSED:
		game_display(game);
		if(player_get_nb_player_alive(game) == 1)
			multi_change_state(game, SCORE);

		break;
	case CHOOSE_MAP:

		map = level_get_curr_map(game_get_curr_level(game));

		w = 10 + 15 + sprite_get_max_width() + 50 + SIZE_BLOC * map_get_width(map);
		h = max(30 * (sprite_get_nb_map_multi() + 1), SIZE_BLOC * map_get_height(map));

		window_resize( w, h);
		window_clear();

		for(int i = 0; i < sprite_get_nb_map_multi(); i++) {
			window_display_image(	sprite_get_map_multi(i),
									10 + 15,
									15 + 30 * i);
		}

		window_display_image(sprite_get_menu(M_S_SELECT_BLACK), 10, 15 + 30 * game_get_pos(game));

		map_display(	map,
						10 + 15 + sprite_get_max_width() + 50,
						(h-(SIZE_BLOC * map_get_height(map))) / 2);
		window_refresh();

		break;
	case SCORE:

		window_clear();
		level_display(game_get_curr_level(game));
		bomb_display(game, level_get_curr_map(game_get_curr_level(game)));
		for(int i = 0; i < game_get_nb_player(game); i++)
			player_display(game_get_player(game, i+1));

		int map_w = map_get_width(level_get_curr_map(game_get_curr_level(game)));
		int map_h = map_get_height(level_get_curr_map(game_get_curr_level(game)));
		int mid_w = map_w / 2 * SIZE_BLOC + map_w%2 * SIZE_BLOC / 2;
		int mid_h = map_h / 2 * SIZE_BLOC + map_h%2 * SIZE_BLOC / 2;

		window_display_image(	sprite_get_menu(M_BG_GREY),
								mid_w - 240,
								mid_h - 262);

		window_display_image(	sprite_get_score(player_get_id_player_alive(game)),
								mid_w - 200,
								mid_h - 222);

		scores = game_get_scores(game);
		for(int i = 0; i < game_get_nb_player(game); i++) {
			window_display_sprite(	sprite_get_players(i+1),
									sprite_get_rect_player_anim(0, i+1, SOUTH),
									mid_w - 200,
									mid_h - 222 + 80 + 80 * i);

			window_display_image(	sprite_get_number_white(scores[i]),
									mid_w - 140,
									mid_h - 222 + 100 + 80 * i);
		}

		window_refresh();

		break;
	}
}
Exemplo n.º 28
0
/**
 * 
 *  rct2: 0x006E8655
 */
static void game_handle_input_mouse(int x, int y, int state)
{
	rct_window *w, *w2;
	rct_widget *widget;
	int widgetIndex;
	rct_windowclass windowClass;
	rct_windownumber windowNumber;

	// Get window and widget under cursor position
	w = window_find_from_point(x, y);
	widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y);
	widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex];

	switch (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8)) {
	case INPUT_STATE_RESET:
		window_tooltip_reset(x, y);
		// fall-through
	case INPUT_STATE_NORMAL:
		switch (state) {
		case 0:
			input_mouseover(x, y, w, widgetIndex);
			break;
		case 1:
			input_leftmousedown(x, y, w, widgetIndex);
			break;
		case 3:
			// Close tooltip
			window_close_by_id(5, 0);
			
			if (w != NULL)
				window_bring_to_front(w);
			
			if (widgetIndex == -1)
				break;
			
			if (widget->type == WWT_VIEWPORT) {
				if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9)
					break;
				w->flags &= ~(1 << 3);
				RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_DRAG;
				RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
				RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
				RCT2_GLOBAL(0x009DE530, rct_windowclass) = w->classification;
				RCT2_GLOBAL(0x009DE52E, rct_windownumber) = w->number;
				RCT2_GLOBAL(0x009DE540, sint16) = 0;
				// hide cursor
				// RCT2_CALLPROC_X(0x00407045, 0, 0, 0, 0, 0, 0, 0);
				// RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 5);

				GetCursorPos(&_dragPosition);
				ShowCursor(FALSE);

			} else if (widget->type == WWT_SCROLL) {

			}

			break;
		}

		break;
	case INPUT_STATE_WIDGET_PRESSED:
		RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_DRAGGING:
		// RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0);

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
		if (w == NULL) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			break;
		}

		if (state == 0) {
			y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
			window_move_position(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
		} else if (state == 2) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
			y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
			window_move_position(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;

			RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0);
		}
		break;
	case INPUT_STATE_VIEWPORT_DRAG:
	{
		int dx, dy;
		
		dx = x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16);
		dy = y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16);
		w = window_find_by_id(RCT2_GLOBAL(0x009DE530, rct_windowclass), RCT2_GLOBAL(0x009DE52E, rct_windownumber));
		if (state == 0) {
			rct_viewport *viewport = w->viewport;
			RCT2_GLOBAL(0x009DE540, sint16) += RCT2_GLOBAL(0x009DE588, sint16);
			if (viewport == NULL) {
				ShowCursor(TRUE);
				RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			} else if (dx != 0 || dy != 0) {
				if (!(w->flags & (1 << 2))) {
					RCT2_GLOBAL(0x009DE540, sint16) = 1000;
					dx <<= viewport->zoom + 1;
					dy <<= viewport->zoom + 1;
					w->var_4B2 += dx;
					w->var_4B4 += dy;
				}
			}
		} else if (state == 4) {
			ShowCursor(TRUE);
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			if (RCT2_GLOBAL(0x009DE540, sint16) < 500) {
				// Right click
				{
					int eax, ebx, ecx, edx, esi, edi, ebp;
					eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16);
					ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16);
					RCT2_CALLFUNC_X(0x006EDE88, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
					switch (ebx & 0xFF) {
					case 2:
						if (*((uint8*)edx) == 0)
							RCT2_CALLPROC_X(0x006B4857, eax, 0, ecx, 0, 0, 0, 0);
						break;
					case 3:
						RCT2_CALLPROC_X(0x006CC056, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 5:
						RCT2_CALLPROC_X(0x006E08D2, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 6:
						RCT2_CALLPROC_X(0x006A614A, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 7:
						RCT2_CALLPROC_X(0x006A61AB, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 8:
						RCT2_CALLPROC_X(0x00666C0E, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 9:
						RCT2_CALLPROC_X(0x006E57A9, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 10:
						RCT2_CALLPROC_X(0x006B88DC, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 12:
						RCT2_CALLPROC_X(0x006BA233, eax, 0, ecx, edx, 0, 0, 0);
						break;
					default:
						break;
					}
				}
			}
		}

		//
		//
		SetCursorPos(_dragPosition.x, _dragPosition.y);
		// RCT2_CALLPROC_X(0x006E89C6, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16), state, widgetIndex, w, widget, 0);
		break;
	}
	case INPUT_STATE_DROPDOWN_ACTIVE:
		RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_VIEWPORT_LEFT:
		RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_SCROLL_LEFT:
		RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_RESIZING:
		// RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0);

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
		if (w == NULL) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			break;
		}

		if (state != 0 && state != 2)
			break;
		if (state == 2) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
		}

		if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) {
			window_resize(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
		}
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
		break;
	case 9:
		RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0);
		break;
	}
}
Exemplo n.º 29
0
static void
get_keys (void)
{
  int search = 0;
  int c, quit = 1;
  uint64_t size1 = 0;

  if (!logger->piping)
    size1 = file_size (conf.ifile);

  while (quit) {
    c = wgetch (stdscr);
    switch (c) {
    case 'q':  /* quit */
      if (!gscroll.expanded) {
        quit = 0;
        break;
      }
      collapse_current_module ();
      break;
    case KEY_F (1):
    case '?':
    case 'h':
      load_help_popup (main_win);
      render_screens ();
      break;
    case 49:   /* 1 */
      /* reset expanded module */
      set_module_to (&gscroll, VISITORS);
      break;
    case 50:   /* 2 */
      /* reset expanded module */
      set_module_to (&gscroll, REQUESTS);
      break;
    case 51:   /* 3 */
      /* reset expanded module */
      set_module_to (&gscroll, REQUESTS_STATIC);
      break;
    case 52:   /* 4 */
      /* reset expanded module */
      set_module_to (&gscroll, NOT_FOUND);
      break;
    case 53:   /* 5 */
      /* reset expanded module */
      set_module_to (&gscroll, HOSTS);
      break;
    case 54:   /* 6 */
      /* reset expanded module */
      set_module_to (&gscroll, OS);
      break;
    case 55:   /* 7 */
      /* reset expanded module */
      set_module_to (&gscroll, BROWSERS);
      break;
    case 56:   /* 8 */
      /* reset expanded module */
      set_module_to (&gscroll, VISIT_TIMES);
      break;
    case 57:   /* 9 */
      /* reset expanded module */
      set_module_to (&gscroll, REFERRERS);
      break;
    case 48:   /* 0 */
      /* reset expanded module */
      set_module_to (&gscroll, REFERRING_SITES);
      break;
    case 33:   /* shift + 1 */
      /* reset expanded module */
      set_module_to (&gscroll, KEYPHRASES);
      break;
    case 34:   /* Shift + 2 */
      /* reset expanded module */
#ifdef HAVE_LIBGEOIP
      set_module_to (&gscroll, GEO_LOCATION);
#else
      set_module_to (&gscroll, STATUS_CODES);
#endif
      break;
#ifdef HAVE_LIBGEOIP
    case 35:   /* Shift + 3 */
      /* reset expanded module */
      set_module_to (&gscroll, STATUS_CODES);
      break;
#endif
    case 9:    /* TAB */
      /* reset expanded module */
      collapse_current_module ();
      if (next_module () == 0)
        render_screens ();
      break;
    case 353:  /* Shift TAB */
      /* reset expanded module */
      collapse_current_module ();
      if (previous_module () == 0)
        render_screens ();
      break;
    case 'g':  /* g = top */
      scroll_to_first_line ();
      display_content (main_win, logger, dash, &gscroll);
      break;
    case 'G':  /* G = down */
      scroll_to_last_line ();
      display_content (main_win, logger, dash, &gscroll);
      break;
      /* expand dashboard module */
    case KEY_RIGHT:
    case 0x0a:
    case 0x0d:
    case 32:   /* ENTER */
    case 79:   /* o */
    case 111:  /* O */
    case KEY_ENTER:
      expand_current_module ();
      display_content (main_win, logger, dash, &gscroll);
      break;
    case KEY_DOWN:     /* scroll main dashboard */
      if ((gscroll.dash + real_size_y) < (unsigned) dash->total_alloc) {
        gscroll.dash++;
        display_content (main_win, logger, dash, &gscroll);
      }
      break;
    case KEY_MOUSE:    /* handles mouse events */
      expand_on_mouse_click ();
      break;
    case 106:  /* j - DOWN expanded module */
      scroll_down_expanded_module ();
      display_content (main_win, logger, dash, &gscroll);
      break;
      /* scroll up main_win */
    case KEY_UP:
      if (gscroll.dash > 0) {
        scroll_up_dashboard ();
        display_content (main_win, logger, dash, &gscroll);
      }
      break;
    case 2:    /* ^ b - page up */
    case 339:  /* ^ PG UP */
      page_up_module ();
      display_content (main_win, logger, dash, &gscroll);
      break;
    case 6:    /* ^ f - page down */
    case 338:  /* ^ PG DOWN */
      page_down_module ();
      display_content (main_win, logger, dash, &gscroll);
      break;
    case 107:  /* k - UP expanded module */
      scroll_up_expanded_module ();
      display_content (main_win, logger, dash, &gscroll);
      break;
    case 'n':
      search_next_match (search);
      break;
    case '/':
      render_search_dialog (search);
      break;
    case 99:   /* c */
      if (conf.no_color)
        break;
      load_schemes_win (main_win);
      free_dashboard (dash);
      allocate_data ();
      render_screens ();
      break;
    case 115:  /* s */
      render_sort_dialog ();
      break;
    case 269:
    case KEY_RESIZE:
      window_resize ();
      break;
    default:
      perform_tail_follow (&size1);
      break;
    }
  }
}
Exemplo n.º 30
0
void multi_change_state(struct game* game, game_state_t state_to) {
	switch(game_get_state(game)) {
	case PLAYING:
	case PAUSED:
		switch(state_to) {
		case SCORE:
#ifdef USE_WIIMOTE
		//= 0)
			//wiimote_set_rumble(player->id, 0);
#endif
			game_set_state(game, SCORE);
			if(player_get_nb_player_alive(game) == 1)
				game_inc_score(game, player_get_id_player_alive(game));

			break;
		case CHOOSE_MAP:
			game_set_state(game, CHOOSE_MAP);
			game_reset_lvl_map(game);
			game_reset_scores(game);

			break;
		default:
			break;
		}
		break;

	case CHOOSE_MAP:
		switch(state_to) {
		case PLAYING:
			game_set_state(game, PLAYING);
			window_resize(map_get_width(level_get_curr_map(game_get_curr_level(game))) * SIZE_BLOC, map_get_height(level_get_curr_map(game_get_curr_level(game))) * SIZE_BLOC + BANNER_HEIGHT + LINE_HEIGHT);
			players_from_map(game, level_get_curr_map(game_get_curr_level(game)));
			player_reset(game, 1, 1, 2, 4, 0);

			break;
		default:
			break;
		}
		break;

	case SCORE:
		switch(state_to) {
		case PLAYING:
			game_set_state(game, PLAYING);
			game_reset_lvl_map(game);
			level_set_cur_map(game_get_curr_level(game), game_get_pos(game));
			players_from_map(game, level_get_curr_map(game_get_curr_level(game)));
			player_reset(game, 1, 1, 2, 4, 0);


			break;
		case CHOOSE_MAP:
			game_set_state(game, CHOOSE_MAP);
			game_reset_lvl_map(game);
			game_reset_scores(game);

			break;
		default:
			break;
		}

		break;
	default:
		break;
	}
}