Exemplo n.º 1
0
static void
notification_is_needed_callback(HippoCanvasItem *item,
                                void            *data)
{
    NotificationNeededInfo *info = data;
    gboolean notify_for_block = TRUE;

    HippoBlock *block;

    g_object_get(G_OBJECT(item), "block", &block, NULL);

    g_debug("Checking if notification is needed for block %s\n", hippo_block_get_guid(block));
    
    if (HIPPO_IS_BLOCK_POST(block)) {
        HippoPost *post;
        
        g_object_get(G_OBJECT(block), "post", &post, NULL);
        if (post) {
            if (chat_is_visible(info->manager, hippo_post_get_guid(post)))
                notify_for_block = FALSE;
            g_object_unref(post);
        }
    } else if (HIPPO_IS_BLOCK_GROUP_CHAT(block)) {
        HippoGroup *group;
        
        g_object_get(G_OBJECT(block), "group", &group, NULL);
        if (group) {
            if (chat_is_visible(info->manager, hippo_entity_get_guid(HIPPO_ENTITY(group))))
                notify_for_block = FALSE;
            g_object_unref(group);
        }
    } else if (block->type == HIPPO_BLOCK_TYPE_MUSIC_CHAT) {
        if (chat_is_visible(info->manager, hippo_block_get_chat_id(block)))
            notify_for_block = FALSE;
    }

    g_object_unref(block);

    if (notify_for_block)
        info->is_needed = TRUE;
}
Exemplo n.º 2
0
void game_view_buttons(UI_WIDGET *widget, unsigned int type, UI_EVENT *e) {
	int scroll_x=0, scroll_y=0;
	int screen_w=platform.screen_w, screen_h=platform.screen_h;
	
	//darnit buttons have no press or release events, we have to handle this ourselves
	
	//View movement
	if(!chat_is_visible(&panelist_game_sidebar)) {
		if(e->buttons->left&&map->cam_x>-((screen_w-sidebar_width)/2))
			scroll_x=-SCROLL_SPEED;
		else if(e->buttons->right&&map->cam_x<map_w-(screen_w-sidebar_width)/2)
			scroll_x=SCROLL_SPEED;
		if(e->buttons->up&&map->cam_y>-(screen_h)/2)
			scroll_y=-SCROLL_SPEED;
		else if(e->buttons->down&&map->cam_y<map_h-screen_h/2)
			scroll_y=SCROLL_SPEED;
			
		if(e->buttons->l) {
			scroll_x*=2;
			scroll_y*=2;
		}
		if(scroll_x||scroll_y) {
			d_map_camera_move(map, map->cam_x+scroll_x, map->cam_y+scroll_y);
			map_minimap_update_viewport();
		}
	}
	if(!(platform.platform&DARNIT_PLATFORM_MAEMO)||e->buttons->select) {
		//Interaction keys
		if(e->buttons->start&&!prevbuttons.start)
			game_state(GAME_STATE_GAME_MENU);
		if(e->buttons->a&&!prevbuttons.a)
			chat_toggle(&panelist_game_sidebar);
		if(e->buttons->b&&!prevbuttons.b) {
			if(building_place>-1) {
				building_place=-1;
			} else if(map_selected_building()) {
				client_message_send(player_id, MSG_SEND_PLACE_BUILDING, BUILDING_NONE, map_selected_index(), NULL);
				map_select_nothing();
			}
		}
		if(e->buttons->x&&!prevbuttons.x) {
			DARNIT_MOUSE m=d_mouse_get();
			UI_EVENT_MOUSE e_m={
				0,
				0,
				UI_EVENT_MOUSE_BUTTON_LEFT,
				0,
			};
			e_m.x=m.x; e_m.y=m.y;
			UI_EVENT e={.mouse=&e_m};
			ui_event_global_send(UI_EVENT_TYPE_MOUSE_PRESS, &e);
		}
		if(e->buttons->y&&!prevbuttons.y) {
			if(building_place==-1&&ability_place==0) {
				int selected_building=map_selected_building();
				if(attacker_target)
					attacker_target=0;
				else if(map_selected_owner()==player_id&&(selected_building==BUILDING_ATTACKER||selected_building==BUILDING_SCOUT))
					attacker_target=1;
			}
		}
	}