Exemplo n.º 1
0
/**
 * Check argument.
 * @param fty function type
 * @param arg argument expression
 * @param argNo the argument's number in function call
 * @param argFull if the function's argument is full
 */
static AstExpression CheckArgument(FunctionType fty, AstExpression arg, int argNo, int *argFull)
{
	Parameter param;
	int parLen = LEN(fty->sig->params);

	arg = Adjust(CheckExpression(arg), 1);

	if (fty->sig->hasProto && parLen == 0)
	{
		*argFull = 1;
		return arg;
	}

	if (argNo == parLen && ! fty->sig->hasEllipse)
		*argFull = 1;
	
	if (! fty->sig->hasProto)
	{
		arg = PromoteArgument(arg);

		if (parLen != 0)
		{
			param = GET_ITEM(fty->sig->params, argNo - 1);
			if (! IsCompatibleType(arg->ty, param->ty))
				goto err;
		}

		return arg;
	}
	else if (argNo <= parLen)
	{
		param = GET_ITEM(fty->sig->params, argNo - 1);
		if (! CanAssign(param->ty, arg))
			goto err;

		if (param->ty->categ < INT)
			arg = Cast(T(INT), arg);
		else
			arg = Cast(param->ty, arg);

		return arg;
	}
	else
	{
		return PromoteArgument(arg);
	}

err:
	Error(&arg->coord, "Incompatible argument");
	return arg;
}
Exemplo n.º 2
0
static inline void*
list_get_next_item(struct list* list, void* item)
{
	if (item == NULL) {
		if (list->link.next == (list_link *)list)
			return NULL;

		return GET_ITEM(list, list->link.next);
	}

	list_link* link = GET_LINK(list, item);
	if (link->next == &list->link)
		return NULL;

	return GET_ITEM(list, link->next);
}
static void TrackSlider(HWND hwndDlg)
{
	int val = SendMessage(GET_ITEM(OUT_Quality_Slider), TBM_GETPOS, (WPARAM)0, (LPARAM)0 );

	char txt[5];
	sprintf_s(txt, 4, "%d", val);

	SetDlgItemText(hwndDlg, OUT_Quality_Readout, txt);
}
Exemplo n.º 4
0
void Cmd_Bandage_f(edict_t * ent)
{

    if ((ent->client->bleeding != 0 || ent->client->leg_damage != 0)
            && ent->client->bandaging != 1)
        ent->client->reload_attempts = 0;	// prevent any further reloading

    if ((ent->client->weaponstate == WEAPON_READY || ent->client->weaponstate == WEAPON_END_MAG)
            && (ent->client->bleeding != 0 || ent->client->leg_damage != 0)
            && ent->client->bandaging != 1) {

        // zucc - check if they have a primed grenade

        if (ent->client->curr_weap == GRENADE_NUM
                && ((ent->client->ps.gunframe >= GRENADE_IDLE_FIRST
                     && ent->client->ps.gunframe <= GRENADE_IDLE_LAST)
                    || (ent->client->ps.gunframe >= GRENADE_THROW_FIRST
                        && ent->client->ps.gunframe <= GRENADE_THROW_LAST)))
        {
            int damage;

            ent->client->ps.gunframe = 0;

            if (use_classic->value)
                damage = 170;
            else
                damage = GRENADE_DAMRAD;

            if(ent->client->quad_framenum > level.framenum)
                damage *= 1.5f;

            fire_grenade2(ent, ent->s.origin, vec3_origin, damage, 0, 2, damage * 2, false);

            INV_AMMO(ent, GRENADE_NUM)--;
            if (INV_AMMO(ent, GRENADE_NUM) <= 0) {
                ent->client->newweapon = GET_ITEM(MK23_NUM);
            }
        }

        ent->client->bandaging = 1;
        ent->client->resp.sniper_mode = SNIPER_1X;
        ent->client->ps.fov = 90;
        ent->client->desired_fov = 90;
        if (ent->client->pers.weapon)
            ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model);
        gi.cprintf(ent, PRINT_HIGH, "You've started bandaging\n");

    } else if (ent->client->bandaging == 1)
        gi.cprintf(ent, PRINT_HIGH, "Already bandaging\n");
    //FIREBLADE 12/26/98 - fix inappropriate message
    else if (ent->client->bleeding == 0 && ent->client->leg_damage == 0)
        gi.cprintf(ent, PRINT_HIGH, "No need to bandage\n");
    else
        gi.cprintf(ent, PRINT_HIGH, "Can't bandage now\n");
    //FIREBLADE
}
Exemplo n.º 5
0
/* 翻译一个复合语句 */
static void TranslateCompoundStatement (AstStatement stmt)
{
	AstCompoundStatement compStmt = AsComp (stmt);
	AstNode p;
	Vector  ilocals = compStmt->ilocals;
	Symbol  v;
	int     i;

    /* 翻译局部变量 */
	for (i = 0; i < LEN (ilocals); ++i) {

		InitData    initd;
		Type        ty;
		Symbol      dst, src;
		int         size;

		v = GET_ITEM (ilocals, i);
		initd   = AsVar(v)->idata;
		size    = 0;
		while (initd != NULL) {

			if (initd->offset != size) {

				dst = CreateOffset (T(UCHAR), v, size);
				GenerateClear (dst, initd->offset - size);
			}

			ty = initd->expr->ty;
			if (initd->expr->op == OP_STR) {

				String str = initd->expr->val.p;
				src = AddString (ArrayOf (str->len + 1, ty->bty), str);
			} else {

				src = TranslateExpression (initd->expr);
			}
			dst = CreateOffset (ty, v, initd->offset);
            /* 赋值 */
			GenerateMove (ty, dst, src);

			size  = initd->offset + ty->size;
			initd = initd->next;
		}

		if (size < v->ty->size) {

			dst = CreateOffset (T(UCHAR), v, size);
			GenerateClear (dst, v->ty->size - size);
		}
	}

	for (p = compStmt->stmts; p; p = p->next) {

		TranslateStatement ((AstStatement)p);
	}
}
Exemplo n.º 6
0
static void TrackField(HWND hwndDlg)
{
	char txt[5];

	UINT chars = GetDlgItemText(hwndDlg, OUT_Quality_Field, txt, 4);

	if(chars)
	{
		int val = atoi(txt);

		if(val >= 0 && val <= 100)
		{
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETPOS, (WPARAM)(BOOL)TRUE, (LPARAM)val);
		}
	}
}
Exemplo n.º 7
0
void DeadDropSpec(edict_t * ent)
{
	gitem_t *spec;
	edict_t *dropped;
	int i;

	for(i = 0; i<ITEM_COUNT; i++)
	{
		if (INV_AMMO(ent, tnums[i]) > 0) {
			spec = GET_ITEM(tnums[i]);
			dropped = Drop_Item(ent, spec);
			// hack the velocity to make it bounce random
			dropped->velocity[0] = (rand() % 600) - 300;
			dropped->velocity[1] = (rand() % 600) - 300;
			dropped->nextthink = level.time + 1;
			dropped->think = MakeTouchSpecThink;
			dropped->owner = NULL;
			dropped->spawnflags = DROPPED_PLAYER_ITEM;
			ent->client->pers.inventory[ITEM_INDEX(spec)] = 0;
		}
	}
}
Exemplo n.º 8
0
void SpawnSpecs(edict_t * ent)
{
	gitem_t *spec;
	edict_t *spot;
	int i;

	if(item_respawnmode->value)
		return;

	for(i = 0; i<ITEM_COUNT; i++)
	{
		if ((spec = GET_ITEM(tnums[i])) != NULL && (spot = FindSpecSpawn()) != NULL) {
			//AQ2:TNG - Igor adding itm_flags
			if ((int)itm_flags->value & items[tnums[i]].flag)
			{
				//gi.dprintf("Spawning special item '%s'.\n", tnames[i]);
				SpawnSpec(spec, spot);
			}
			//AQ2:TNG End adding itm_flags
		}
	}
}
Exemplo n.º 9
0
void SpawnSpecs(edict_t * ent)
{
	gitem_t *spec;
	edict_t *spot;
	int i, itemNum;

	G_FreeEdict(ent);

	if(item_respawnmode->value)
		return;

	for(i = 0; i<ITEM_COUNT; i++)
	{
		itemNum = ITEM_FIRST + i;
		if (!ITF_ALLOWED(itemNum))
			continue;

		if ((spec = GET_ITEM(itemNum)) != NULL && (spot = FindSpecSpawn()) != NULL) {
			//gi.dprintf("Spawning special item '%s'.\n", tnames[i]);
			SpawnSpec(spec, spot);
		}
	}
}
Exemplo n.º 10
0
void DeadDropSpec(edict_t * ent)
{
	gitem_t *spec;
	edict_t *dropped;
	int i, itemNum;

	for(i = 0; i<ITEM_COUNT; i++)
	{
		itemNum = ITEM_FIRST + i;
		if (INV_AMMO(ent, itemNum) > 0) {
			spec = GET_ITEM(itemNum);
			dropped = Drop_Item(ent, spec);
			// hack the velocity to make it bounce random
			dropped->velocity[0] = (rand() % 600) - 300;
			dropped->velocity[1] = (rand() % 600) - 300;
			dropped->nextthink = level.framenum + 1 * HZ;
			dropped->think = MakeTouchSpecThink;
			dropped->owner = NULL;
			dropped->spawnflags = DROPPED_PLAYER_ITEM;
			ent->client->inventory[ITEM_INDEX(spec)] = 0;
		}
	}
}
Exemplo n.º 11
0
static void DAssemUIL(IRInst inst)
{
	int op = inst->opcode;

	fprintf(IRFile, "\t");
	switch (op)
	{
	case BOR: 
	case BXOR: 
	case BAND:
	case LSH: 
	case RSH:
	case ADD:
	case SUB:
	case MUL: 
	case DIV: 
	case MOD:
		fprintf(IRFile, "%s = %s %s %s", DST->name, SRC1->name, OPCodeNames[op], SRC2->name);
		break;

	case INC:
	case DEC:
		fprintf(IRFile, "%s%s", OPCodeNames[op], DST->name);
		break;

	case BCOM:
	case NEG:
	case ADDR:
	case DEREF:
		fprintf(IRFile, "%s = %s%s", DST->name, OPCodeNames[op], SRC1->name);
		break;

	case MOV:
		fprintf(IRFile, "%s = %s", DST->name, SRC1->name);
		break;

	case IMOV:
		fprintf(IRFile, "*%s = %s", DST->name, SRC1->name);
		break;

	case JE:
	case JNE:
	case JG:
	case JL:
	case JGE:
	case JLE:
		fprintf(IRFile, "if (%s %s %s) goto %s", SRC1->name, OPCodeNames[op],
			    SRC2->name, ((BBlock)DST)->sym->name);
		break;

	case JZ:
		fprintf(IRFile, "if (! %s) goto %s", SRC1->name, ((BBlock)DST)->sym->name);
		break;

	case JNZ:
		fprintf(IRFile, "if (%s) goto %s", SRC1->name, ((BBlock)DST)->sym->name);
		break;

	case JMP:
		fprintf(IRFile, "goto %s", ((BBlock)DST)->sym->name);
		break;

	case IJMP:
		{
			BBlock *p = (BBlock *)DST;

			fprintf(IRFile, "goto (");
			while (*p != NULL)
			{
				fprintf(IRFile, "%s,",  (*p)->sym->name);
				p++;
			}
			fprintf(IRFile, ")[%s]", SRC1->name);
		}
		break;

	case CALL:
		{
			ILArg arg;
			Vector args = (Vector)SRC2;
			int i;

			if (DST != NULL)
			{
				fprintf(IRFile, "%s = ", DST->name);
			}
			fprintf(IRFile, "%s(", SRC1->name);
			for (i = 0; i < LEN(args); ++i)
			{
				arg = GET_ITEM(args, i);
				if (i != LEN(args) - 1)
					fprintf(IRFile, "%s, ", arg->sym->name);
				else
					fprintf(IRFile, "%s", arg->sym->name);
			}
			fprintf(IRFile, ")");
		}
		break;

	case RET:
		fprintf(IRFile, "return %s", DST->name);
		break;

	default:
		fprintf(IRFile, "%s = %s%s", DST->name, OPCodeNames[op], SRC1->name);
		break;
	}
	fprintf(IRFile, ";\n");
}
Exemplo n.º 12
0
void Cmd_Choose_f(edict_t * ent)
{
    char *s;
    int itemNum = NO_NUM;

    // only works in teamplay
    if ((!teamplay->value && !dm_choose->value) || teamdm->value || ctf->value == 2)
        return;

    s = gi.args();

    // convert names a player might try (DW added a few)
    if (!Q_stricmp(s, "A 2nd pistol") || !Q_stricmp(s, "railgun") || !Q_stricmp(s, "akimbo") || !Q_stricmp(s, DUAL_NAME))
        itemNum = DUAL_NUM;
    else if (!Q_stricmp(s, "shotgun") || !Q_stricmp(s, M3_NAME))
        itemNum = M3_NUM;
    else if (!Q_stricmp(s, "machinegun") || !Q_stricmp(s, HC_NAME))
        itemNum = HC_NUM;
    else if (!Q_stricmp(s, "super shotgun") || !Q_stricmp(s, "mp5") || !Q_stricmp(s, MP5_NAME))
        itemNum = MP5_NUM;
    else if (!Q_stricmp(s, "chaingun") || !Q_stricmp(s, "sniper") || !Q_stricmp(s, SNIPER_NAME))
        itemNum = SNIPER_NUM;
    else if (!Q_stricmp(s, "bfg10k") || !Q_stricmp(s, KNIFE_NAME))
        itemNum = KNIFE_NUM;
    else if (!Q_stricmp(s, "grenade launcher") || !Q_stricmp(s, "m4") || !Q_stricmp(s, M4_NAME))
        itemNum = M4_NUM;
    else if (!Q_stricmp(s, "laser") || !Q_stricmp(s, LASER_NAME))
        itemNum = LASER_NUM;
    else if (!Q_stricmp(s, "vest") || !Q_stricmp(s, KEV_NAME))
        itemNum = KEV_NUM;
    else if (!Q_stricmp(s, "slippers") || !Q_stricmp(s, SLIP_NAME))
        itemNum = SLIP_NUM;
    else if (!Q_stricmp(s, SIL_NAME))
        itemNum = SIL_NUM;
    else if (!Q_stricmp(s, "helmet") || !Q_stricmp(s, HELM_NAME))
        itemNum = HELM_NUM;
    else if (!Q_stricmp(s, BAND_NAME))
        itemNum = BAND_NUM;


    switch(itemNum) {
    case DUAL_NUM:
    case M3_NUM:
    case HC_NUM:
    case MP5_NUM:
    case SNIPER_NUM:
    case KNIFE_NUM:
    case M4_NUM:
        if (!((int)wp_flags->value & items[itemNum].flag)) {
            gi.cprintf(ent, PRINT_HIGH, "Weapon disabled on this server.\n");
            return;
        }
        ent->client->resp.weapon = GET_ITEM(itemNum);
        break;
    case LASER_NUM:
    case KEV_NUM:
    case SLIP_NUM:
    case SIL_NUM:
    case HELM_NUM:
    case BAND_NUM:
        if (!((int)itm_flags->value & items[itemNum].flag)) {
            gi.cprintf(ent, PRINT_HIGH, "Item disabled on this server.\n");
            return;
        }
        ent->client->resp.item = GET_ITEM(itemNum);
        break;
    default:
        gi.cprintf(ent, PRINT_HIGH, "Invalid weapon or item choice.\n");
        return;
    }

    gi.cprintf(ent, PRINT_HIGH, "Weapon selected: %s\nItem selected: %s\n",
               (ent->client->resp.weapon)->pickup_name, (ent->client->resp.item)->pickup_name);
}
Exemplo n.º 13
0
// Handles weapon reload requests
void Cmd_Reload_f(edict_t * ent)
{
    //+BD - If the player is dead, don't bother
    if (ent->deadflag == DEAD_DEAD) {
        //gi.centerprintf(ent, "I know you're a hard ass,\nBUT YOU'RE F*****G DEAD!!\n");
        return;
    }

    if (ent->client->weaponstate == WEAPON_BANDAGING ||
            ent->client->bandaging == 1 ||
            ent->client->bandage_stopped == 1 ||
            ent->client->weaponstate == WEAPON_ACTIVATING ||
            ent->client->weaponstate == WEAPON_DROPPING || ent->client->weaponstate == WEAPON_FIRING) {
        return;
    }

    if (!ent->client->fast_reload)
        ent->client->reload_attempts--;
    if (ent->client->reload_attempts < 0)
        ent->client->reload_attempts = 0;

    //First, grab the current magazine max count...

    //Set the weaponstate...
    switch(ent->client->curr_weap) {
    case M3_NUM:
        if (ent->client->shot_rds >= ent->client->shot_max)
            return;

        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        // already in the process of reloading!
        if (ent->client->weaponstate == WEAPON_RELOADING &&
                (ent->client->shot_rds < (ent->client->shot_max - 1)) &&
                !(ent->client->fast_reload) &&
                ((ent->client->pers.inventory[ent->client->ammo_index] - 1) > 0)) {
            // don't let them start fast reloading until far enough into the firing sequence
            // this gives them a chance to break off from reloading to fire the weapon - zucc
            if (ent->client->ps.gunframe >= 48) {
                ent->client->fast_reload = 1;
                (ent->client->pers.inventory[ent->client->ammo_index])--;
            } else {
                ent->client->reload_attempts++;
            }
        }
        break;
    case HC_NUM:
        if (ent->client->cannon_rds >= ent->client->cannon_max)
            return;

        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        if(hc_single->value)
        {
            if(ent->client->resp.hc_mode || ent->client->cannon_rds == 1)
            {   if(ent->client->pers.inventory[ent->client->ammo_index] < 1)
                    return;
            }
            else if(ent->client->pers.inventory[ent->client->ammo_index] < 2)
                return;
        }
        else if (ent->client->pers.inventory[ent->client->ammo_index] < 2)
            return;
        break;
    case SNIPER_NUM:
        if (ent->client->sniper_rds >= ent->client->sniper_max)
            return;

        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        // already in the process of reloading!
        if (ent->client->weaponstate == WEAPON_RELOADING
                && (ent->client->sniper_rds < (ent->client->sniper_max - 1))
                && !(ent->client->fast_reload)
                && ((ent->client->pers.inventory[ent->client->ammo_index] - 1) > 0)) {
            // don't let them start fast reloading until far enough into the firing sequence
            // this gives them a chance to break off from reloading to fire the weapon - zucc
            if (ent->client->ps.gunframe >= 72) {
                ent->client->fast_reload = 1;
                (ent->client->pers.inventory[ent->client->ammo_index])--;
            } else {
                ent->client->reload_attempts++;
            }
        }
        ent->client->ps.fov = 90;
        if (ent->client->pers.weapon)
            ent->client->ps.gunindex = gi.modelindex(ent->client->pers.weapon->view_model);
        break;
    case DUAL_NUM:
        if (ent->client->dual_rds == ent->client->dual_max)
            return;

        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        //TempFile change to pistol, then reload
        if (ent->client->pers.inventory[ent->client->ammo_index] == 1) {
            gitem_t *it;

            it = GET_ITEM(MK23_NUM);
            it->use(ent, it);
            ent->client->autoreloading = true;
            return;
        }

        break;
    case MP5_NUM:
        if (ent->client->mp5_rds == ent->client->mp5_max)
            return;
        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        break;
    case M4_NUM:
        if (ent->client->m4_rds == ent->client->m4_max)
            return;
        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        break;
    case MK23_NUM:
        if (ent->client->mk23_rds == ent->client->mk23_max)
            return;
        if(ent->client->pers.inventory[ent->client->ammo_index] <= 0) {
            gi.cprintf(ent, PRINT_HIGH, "Out of ammo\n");
            return;
        }
        break;
    default:
        //We should never get here, but...
        //BD 5/26 - Actually we get here quite often right now. Just exit for weaps that we
        //          don't want reloaded or that never reload (grenades)
        return;
    }

    ent->client->weaponstate = WEAPON_RELOADING;
}
Exemplo n.º 14
0
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
    BOOL fError; 
 
    switch(message) 
    { 
		case WM_INITDIALOG:
			SET_CHECK(OUT_Lossless_Check, g_lossless);

			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMIN, (WPARAM)(BOOL)FALSE, (LPARAM)1);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMAX, (WPARAM)(BOOL)FALSE, (LPARAM)100);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETPOS, (WPARAM)(BOOL)TRUE, (LPARAM)g_quality);

			ADD_MENU_ITEM(OUT_BitDepth_Menu, 0, "Auto", DIALOG_BITDEPTH_AUTO, (g_bit_depth == DIALOG_BITDEPTH_AUTO));
			ADD_MENU_ITEM(OUT_BitDepth_Menu, 1, "8-bit", DIALOG_BITDEPTH_8, (g_bit_depth == DIALOG_BITDEPTH_8));
			ADD_MENU_ITEM(OUT_BitDepth_Menu, 2, "16-bit", DIALOG_BITDEPTH_16, (g_bit_depth == DIALOG_BITDEPTH_16));
			ADD_MENU_ITEM(OUT_BitDepth_Menu, 3, "16-bit float", DIALOG_BITDEPTH_16_FLOAT, (g_bit_depth == DIALOG_BITDEPTH_16_FLOAT));
			ADD_MENU_ITEM(OUT_BitDepth_Menu, 4, "32-bit float", DIALOG_BITDEPTH_32_FLOAT, (g_bit_depth == DIALOG_BITDEPTH_32_FLOAT));

			ADD_MENU_ITEM(OUT_Codec_Menu, 0, "Auto", DIALOG_CODEC_AUTO, (g_codec == DIALOG_CODEC_AUTO));
			ADD_MENU_ITEM(OUT_Codec_Menu, 1, "Dirac", DIALOG_CODEC_DIRAC, (g_codec == DIALOG_CODEC_DIRAC));
			ADD_MENU_ITEM(OUT_Codec_Menu, 2, "OpenEXR", DIALOG_CODEC_OPENEXR, (g_codec == DIALOG_CODEC_OPENEXR));
			ADD_MENU_ITEM(OUT_Codec_Menu, 3, "PNG", DIALOG_CODEC_PNG, (g_codec == DIALOG_CODEC_PNG));
			ADD_MENU_ITEM(OUT_Codec_Menu, 4, "Uncompressed", DIALOG_CODEC_UNCOMPRESSED, (g_codec == DIALOG_CODEC_UNCOMPRESSED));

			TrackSlider(hwndDlg);
			TrackLossless(hwndDlg);

			return TRUE;
 
		case WM_NOTIFY:
			switch(LOWORD(wParam))
			{
				case OUT_Quality_Slider:
					TrackSlider(hwndDlg);
				return TRUE;
			}
		return FALSE;

        case WM_COMMAND: 
			g_item_clicked = LOWORD(wParam);

            switch(g_item_clicked)
            { 
                case OUT_OK: 
				case OUT_Cancel:  // do the same thing, but g_item_clicked will be different
					g_lossless = GET_CHECK(OUT_Lossless_Check);
					g_quality = SendMessage(GET_ITEM(OUT_Quality_Slider), TBM_GETPOS, (WPARAM)0, (LPARAM)0 );
					g_bit_depth = (DialogBitDepth)GET_MENU_VALUE(OUT_BitDepth_Menu);
					g_codec = (DialogCodec)GET_MENU_VALUE(OUT_Codec_Menu);

					EndDialog(hwndDlg, 0);
					return TRUE;

				case OUT_Lossless_Check:
					TrackLossless(hwndDlg);
					return TRUE;
            } 
    } 
    return FALSE; 
} 
Exemplo n.º 15
0
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
    BOOL fError; 
 
    switch(message) 
    { 
		case WM_INITDIALOG:
			SET_CHECK(OUT_Lossless_Radio, g_lossless);
			SET_CHECK(OUT_Lossy_Radio, !g_lossless);

			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMIN, (WPARAM)(BOOL)FALSE, (LPARAM)0);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETRANGEMAX, (WPARAM)(BOOL)FALSE, (LPARAM)100);
			SendMessage(GET_ITEM(OUT_Quality_Slider),(UINT)TBM_SETPOS, (WPARAM)(BOOL)TRUE, (LPARAM)g_quality);

			if(!g_have_transparency)
			{
				ENABLE_ITEM(OUT_Alpha_Radio_Transparency, FALSE);

				if(g_alpha == DIALOG_ALPHA_TRANSPARENCY)
				{
					g_alpha = (g_alpha_name != NULL ? DIALOG_ALPHA_CHANNEL : DIALOG_ALPHA_NONE);
				}
			}

			if(g_alpha_name == NULL)
			{
				ENABLE_ITEM(OUT_Alpha_Radio_Channel, FALSE);

				if(g_alpha == DIALOG_ALPHA_CHANNEL)
				{
					g_alpha = (g_have_transparency ? DIALOG_ALPHA_TRANSPARENCY : DIALOG_ALPHA_NONE);
				}
			}
			else
			{
				SetDlgItemText(hwndDlg, OUT_Alpha_Radio_Channel, g_alpha_name);
			}

			SET_CHECK( (g_alpha == DIALOG_ALPHA_NONE ? OUT_Alpha_Radio_None :
						g_alpha == DIALOG_ALPHA_TRANSPARENCY ? OUT_Alpha_Radio_Transparency :
						g_alpha == DIALOG_ALPHA_CHANNEL ? OUT_Alpha_Radio_Channel :
						OUT_Alpha_Radio_None), TRUE);

			SET_CHECK(OUT_Alpha_Cleanup_Check, g_alpha_cleanup);
			SET_CHECK(OUT_Lossy_Alpha_Check, g_lossy_alpha);
			SET_CHECK(OUT_Save_Metadata_Check, g_save_metadata);

			TrackLossless(hwndDlg);
			TrackSlider(hwndDlg);
			TrackAlpha(hwndDlg);

			return TRUE;
 
		case WM_NOTIFY:
			switch(LOWORD(wParam))
			{
				case OUT_Quality_Slider:
					TrackSlider(hwndDlg);
				return TRUE;
			}
		return FALSE;

        case WM_COMMAND: 
			g_item_clicked = LOWORD(wParam);

            switch(g_item_clicked)
            { 
                case OUT_OK: 
				case OUT_Cancel:  // do the same thing, but g_item_clicked will be different
					g_lossless = GET_CHECK(OUT_Lossless_Radio);
					g_quality = SendMessage(GET_ITEM(OUT_Quality_Slider), TBM_GETPOS, (WPARAM)0, (LPARAM)0 );

					g_alpha =	GET_CHECK(OUT_Alpha_Radio_None) ? DIALOG_ALPHA_NONE :
								GET_CHECK(OUT_Alpha_Radio_Transparency) ? DIALOG_ALPHA_TRANSPARENCY :
								GET_CHECK(OUT_Alpha_Radio_Channel) ? DIALOG_ALPHA_CHANNEL :
								DIALOG_ALPHA_TRANSPARENCY;

					g_alpha_cleanup = GET_CHECK(OUT_Alpha_Cleanup_Check);
					g_lossy_alpha = GET_CHECK(OUT_Lossy_Alpha_Check);
					g_save_metadata = GET_CHECK(OUT_Save_Metadata_Check);

					EndDialog(hwndDlg, 0);
					return TRUE;


				case OUT_Lossless_Radio:
				case OUT_Lossy_Radio:
					TrackLossless(hwndDlg);
					return TRUE;

				case OUT_Alpha_Radio_None:
				case OUT_Alpha_Radio_Transparency:
				case OUT_Alpha_Radio_Channel:
					TrackAlpha(hwndDlg);

				case OUT_Quality_Field:
					TrackField(hwndDlg);
					return TRUE;
            } 
    } 
    return FALSE; 
}