Esempio n. 1
0
THexEdit::THexEdit(menu_item_t *my_menu) : TEdit(my_menu)
{
    maxl = menu->values_list[0];
    field = (char*)malloc(maxl+1);
    the_hex = (UINT32 *)menu->values_list_label[1];
    char buf[20];
    copy_hex(buf,menu->values_list_label[2],20);
    sscanf(buf,"%i",&min);
    copy_hex(buf,menu->values_list_label[3],20);
    sscanf(buf,"%i",&max);
    sprintf(field,"%x",*the_hex);
    use_hist = 0;
    pos = strlen(field);
}
Esempio n. 2
0
/* Make a copy of an existing map
 */
Map *map_copy(const Map * map)
{
	Map *copy = map_new();
	int x, y;

	copy->y = map->y;
	copy->x_size = map->x_size;
	copy->y_size = map->y_size;
	for (y = 0; y < MAP_SIZE; y++)
		for (x = 0; x < MAP_SIZE; x++)
			copy->grid[y][x] = copy_hex(copy, map->grid[y][x]);
	map_traverse(copy, build_network, NULL);
	map_traverse(copy, connect_network, NULL);
	map_traverse_const(map, set_nosetup_nodes, copy);
	if (map->robber_hex == NULL)
		copy->robber_hex = NULL;
	else
		copy->robber_hex =
		    copy->grid[map->robber_hex->y][map->robber_hex->x];
	if (map->pirate_hex == NULL)
		copy->pirate_hex = NULL;
	else
		copy->pirate_hex =
		    copy->grid[map->pirate_hex->y][map->pirate_hex->x];
	copy->shrink_left = map->shrink_left;
	copy->shrink_right = map->shrink_right;
	copy->has_moved_ship = map->has_moved_ship;
	copy->have_bridges = map->have_bridges;
	copy->has_pirate = map->has_pirate;
	copy->shrink_left = map->shrink_left;
	copy->shrink_right = map->shrink_right;
	copy->chits = copy_int_list(map->chits);

	return copy;
}
Esempio n. 3
0
int THexEdit::handle_key(SDL_Event *event) {
    int ret = TEdit::handle_key(event);
    // The handler is called by the dialog when handle_key returns 1, so we do
    // the conversion just before
    if (ret == 1) {
	char buf[20];
	copy_hex(buf,field,20);
	sscanf(buf,"%i",the_hex);
    }
    return ret;
}