Esempio n. 1
0
/*
 * GuildShieldDialogProc:  Dialog procedure for guild shield dialog.
 */
BOOL CALLBACK GuildShieldDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:

		hwndShieldPage = hDlg;
		GuildShieldControl(GetDlgItem(hDlg, IDC_SHIELD));

		RequestGuildShieldSamples();
		RequestGuildShield();

		// claimant guild control holds format ("claimed by %s")
		SetWindowFont(GetDlgItem(hDlg, IDC_STATIC_GUILD), GetFont(FONT_LIST), FALSE);
		GetDlgItemText(hDlg, IDC_STATIC_GUILD, szClaimFormat, sizeof(szClaimFormat));

		// claimant guild control starts with "can't use those colors" since it's grey+grey
		GetDlgItemText(hDlg, IDC_RENOUNCE, szClaimBuffer, sizeof(szClaimBuffer));
		SetDlgItemText(hDlg, IDC_STATIC_GUILD, szClaimBuffer);

		CenterWindow(hDlg, GetParent(hDlg));
		return TRUE;

	case WM_COMMAND:
		switch(GET_WM_COMMAND_ID(wParam, lParam))
		{

		// in range [1,iNumPatterns]
		case IDC_PATTERN_PREV:
			iChosenPattern--;
			if(iChosenPattern < 1)
				iChosenPattern = iNumPatterns;
			break;
		case IDC_PATTERN_NEXT:
			iChosenPattern++;
			if(iChosenPattern > iNumPatterns)
				iChosenPattern = 1;
			break;

		// in range [0,iNumColors-1]
		case IDC_COLOR1_PREV:
			iChosenColor1--;
			if(iChosenColor1 < 0)
				iChosenColor1 = iNumColors - 1;
			break;
		case IDC_COLOR1_NEXT:
			iChosenColor1++;
			if(iChosenColor1 >= iNumColors)
				iChosenColor1 = 0;
			break;
		case IDC_COLOR2_PREV:
			iChosenColor2--;
			if(iChosenColor2 < 0)
				iChosenColor2 = iNumColors - 1;
			break;
		case IDC_COLOR2_NEXT:
			iChosenColor2++;
			if(iChosenColor2 >= iNumColors)
				iChosenColor2 = 0;
			break;

		case IDC_ACCEPT:
			if (legalShield(iChosenColor1,iChosenColor2,iChosenPattern))
			{
				RequestClaimGuildShield(iChosenColor1, iChosenColor2, iChosenPattern);
			}
			break;
		}
		RequestFindGuildShield(iChosenColor1, iChosenColor2, iChosenPattern);
		GuildShieldDraw();
		return FALSE;

	case WM_SHOWWINDOW:
		if (!(BOOL)wParam)
			RequestGuildShield();
		break;

	case WM_DRAWITEM:
		GuildShieldControl(GetDlgItem(hDlg, IDC_SHIELD));
		GuildShieldDraw();
		return TRUE;

	case WM_DESTROY:
		hwndShieldPage = NULL;
		return FALSE;
	}
	return FALSE;
}
Esempio n. 2
0
/*
 * GuildMemberDialogProc:  Dialog procedure for guild membership dialog.
 */
BOOL CALLBACK GuildMemberDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
    HWND hList;
    int i, index, flags;

    switch (message)
    {
    case WM_INITDIALOG:
        hList = GetDlgItem(hDlg, IDC_GUILDLIST);
        SetWindowFont(hList, GetFont(FONT_LIST), FALSE);
        SetWindowFont(GetDlgItem(hDlg, IDC_RANK), GetFont(FONT_LIST), FALSE);

        // Add guild members to list box
        num_rank4 = 0;
        for (i=0; i < guild_info->num_users; i++)
        {
            GuildMember *member = &guild_info->members[i];
            index = ListBox_AddString(hList, member->name);
            ListBox_SetItemData(hList, index, member);

            if (member->id == cinfo->player->id)
                guild_info->rank = member->rank;

            if (member->id == guild_info->current_vote)
                SetWindowText(GetDlgItem(hDlg, IDC_CURRENTVOTE), member->name);

            if (member->rank == 4)
                num_rank4++;
        }

        if (guild_info->current_vote == 0)
            SetWindowText(GetDlgItem(hDlg, IDC_CURRENTVOTE), GetString(hInst, IDS_NOBODY));

        flags = guild_info->flags;

        // Destroy buttons for commands we don't have
        if (!(flags & GC_EXILE))
            DestroyWindow(GetDlgItem(hDlg, IDC_EXILE));

        if (!(flags & GC_RENOUNCE))
            DestroyWindow(GetDlgItem(hDlg, IDC_RENOUNCE));

        if (!(flags & GC_ABDICATE))
        {
            DestroyWindow(GetDlgItem(hDlg, IDC_ABDICATE));
            DestroyWindow(GetDlgItem(hDlg, IDC_ABDICATENAME));
        }

        if (!(flags & GC_VOTE))
        {
            DestroyWindow(GetDlgItem(hDlg, IDC_VOTE));
            DestroyWindow(GetDlgItem(hDlg, IDC_VOTENAME));
        }

        if (!(flags & GC_SET_RANK))
            DestroyWindow(GetDlgItem(hDlg, IDC_RANK));
        else DestroyWindow(GetDlgItem(hDlg, IDC_RANKDISPLAY));

        CenterWindow(hGuildConfigDialog, GetParent(hGuildConfigDialog));
        GuildShieldControl(GetDlgItem(hDlg, IDC_SHIELD));
        RequestGuildShieldSamples();
        RequestGuildShield();
        return TRUE;

        HANDLE_MSG(hDlg, WM_COMMAND, GuildMemberCommand);

    case WM_SHOWWINDOW:
        if (!(BOOL)wParam)
            RequestGuildShield();
        break;

    case WM_DRAWITEM:
        if (wParam == IDC_SHIELD)
        {
            GuildShieldControl(GetDlgItem(hDlg, IDC_SHIELD));
            GuildShieldDraw();
            return TRUE;
        }
        return GuildListDrawItem(hDlg, (const DRAWITEMSTRUCT *)(lParam));
    }
    return FALSE;
}