main_gui.c
changeset 724 a73dec475b53
parent 722 f420fa9bd521
child 758 423ae0bcba07
equal deleted inserted replaced
723:edd37e6da51f 724:a73dec475b53
   665 		int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y);
   665 		int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y);
   666 		int action_id = WP(w,menu_d).action_id;
   666 		int action_id = WP(w,menu_d).action_id;
   667 
   667 
   668 		// We have a new entry at the top of the list of menu 9 when networking
   668 		// We have a new entry at the top of the list of menu 9 when networking
   669 		//  so keep that in count
   669 		//  so keep that in count
   670 		if (!_networking || (WP(w,menu_d).main_button == 9 && index > 0)) {
   670 		if (_networking && WP(w,menu_d).main_button == 9) {
   671 			index = GetPlayerIndexFromMenu(index-1)+1;
   671 			if (index > 0)
   672 		}
   672 			 index = GetPlayerIndexFromMenu(index - 1) + 1;
       
   673 		} else
       
   674 			index = GetPlayerIndexFromMenu(index);
   673 
   675 
   674 		if (index < 0) {
   676 		if (index < 0) {
   675 			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
   677 			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
   676 			if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
   678 			if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
   677 				index = WP(w,menu_d).sel_index;
   679 				index = WP(w,menu_d).sel_index;
   690 		UpdatePlayerMenuHeight(w);
   692 		UpdatePlayerMenuHeight(w);
   691 		index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y);
   693 		index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y);
   692 
   694 
   693 		// We have a new entry at the top of the list of menu 9 when networking
   695 		// We have a new entry at the top of the list of menu 9 when networking
   694 		//  so keep that in count
   696 		//  so keep that in count
   695 		if (index != -1) {
   697 		if (_networking && WP(w,menu_d).main_button == 9) {
   696 			if (!_networking || (WP(w,menu_d).main_button == 9 && index != 0)) {
   698 			if (index > 0)
   697 				index = GetPlayerIndexFromMenu(index-1)+1;
   699 			 index = GetPlayerIndexFromMenu(index - 1) + 1;
   698 			}
   700 		} else
   699 		}
   701 			index = GetPlayerIndexFromMenu(index);
   700 
   702 
   701 		if (index == -1 || index == WP(w,menu_d).sel_index)
   703 		if (index == -1 || index == WP(w,menu_d).sel_index)
   702 			return;
   704 			return;
   703 
   705 
   704 		WP(w,menu_d).sel_index = index;
   706 		WP(w,menu_d).sel_index = index;
   746 
   748 
   747 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
   749 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
   748 	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
   750 	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
   749 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
   751 	w->flags4 &= ~WF_WHITE_BORDER_MASK;
   750 	WP(w,menu_d).item_count = 0;
   752 	WP(w,menu_d).item_count = 0;
   751 	WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : 0;
   753 	WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
   752 	if (_networking && main_button == 9 && _local_player != OWNER_SPECTATOR) {
   754 	if (_networking && main_button == 9) {
   753 		WP(w,menu_d).sel_index++;
   755 		if (_local_player != OWNER_SPECTATOR)
       
   756 			WP(w,menu_d).sel_index++;
       
   757 		else
       
   758 			/* Select client list by default for spectators */
       
   759 			WP(w,menu_d).sel_index = 0;
   754 	}
   760 	}
   755 	WP(w,menu_d).action_id = main_button;
   761 	WP(w,menu_d).action_id = main_button;
   756 	WP(w,menu_d).main_button = main_button;
   762 	WP(w,menu_d).main_button = main_button;
   757 	WP(w,menu_d).checked_items = gray;
   763 	WP(w,menu_d).checked_items = gray;
   758 	_popup_menu_active = true;
   764 	_popup_menu_active = true;