📄 suoha_main.c
字号:
if (winIsFocussed(data->win)==0)
winfocusout=1;
else
winfocusout=0;
switch (e)
{
case MfwWinVisible:
dspl_ClearAll();
switch (win_states)
{
case SUOHA_START_ANI:
win_states = SUOHA_START_ANI;
animation_i=0; animation_j=0; animation_k=0;
Suoha_Display_Start_Picture();
time_ani_state = TIMER_START_ANI_PIC2;
timStart(data->tim);
break;
case SUOHA_OPP_SELECT:
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, focus_opp);
break;
case SUOHA_SAVE_MONEY:
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, focus_opp);
DisplayDialog(isorsaved);
break;
case SUOHA_MAIN_WINDOW:
if (mainwin_states & SUOHA_ISCHECKING)
CheckCurr();
else
RedrawMainWin();
if (winfocusout==1)
{
if (data->timNeedStart==1)
timStart(data->tim);
}
break;
case SUOHA_MON_PUB:
EndOne();
break;
default:
break;
}
break;
default:
break;
}
return MFW_EVENT_CONSUMED;
}
static int Suoha_Kbd_Cb(MfwEvt e, MfwKbd *k)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_Suoha * data = (T_Suoha *)win_data->user;
UBYTE preMM = 1;
USHORT i;
MfwRect rect = {LEFT_OPPTXT, TOP_OPPTXT, RIGHT_OPPTXT-LEFT_OPPTXT, BOTTOM_OPPTXT-TOP_OPPTXT};
switch (win_states)
{
case SUOHA_START_ANI: //suoha is starting and welcome animation is showing
timStop(data->tim);
animation_i = animation_j = animation_k = 0;
Opponent_Select_init();
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, 1);
break;
case SUOHA_OPP_SELECT: //select an opponent among three ones to play with
switch (k->code)
{
case KCD_MNUUP: //select an opp and loop
preMM = focus_opp;
focus_opp = focus_opp -1 ;
if (focus_opp == 0)
focus_opp = 4;
DisplayMMFigure(focus_opp, preMM);
break;
case KCD_MNUDOWN: //select an opp and loop
preMM = focus_opp;
focus_opp = focus_opp+1;
if (focus_opp>4)
focus_opp = 1;
DisplayMMFigure(focus_opp, preMM);
break;
case KCD_LEFT: //enter main interface of playing suoha game
case KCD_OK:
if (focus_opp<4) //zhangzg 08/14/2002
{
if (oppmoney[focus_opp-1]>=100 && p_M>=100) //the opponent has money!! 100 means the bottom stake, so the money they have must be over 100
{
timDelete(data->tim);
data->tim = timCreate(data->win, WAIT_TIME, (MfwCb)Suoha_Tim_Cb);
Play_MainWin_data_Init();
Play_Start();
} else if (p_M<100)
{
PaintBackground(rect, 0xffff80); //淡黄色
dspl_TextOut(LEFT_OPPTXT+3, 50, DSPL_TXTATTR_UNICODE| DSPL_TXTATTR_TRANSPARENT, (char *)duibuqi);
dspl_TextOut(LEFT_OPPTXT+3, 66, DSPL_TXTATTR_UNICODE| DSPL_TXTATTR_TRANSPARENT, (char *)buzhu);
}
}
break;
case KCD_RIGHT:
case KCD_HUP: //back to the menu of games
if ( oppmoney[0] == p_c_money.opp1_money &&
oppmoney[1] == p_c_money.opp2_money &&
oppmoney[2] == p_c_money.opp3_money &&
p_M == p_c_money.player_money) //if no changes
Suoha_Destroy(win);
else
{
win_states = SUOHA_SAVE_MONEY;
isorsaved=1;
DisplayDialog(isorsaved);
}
break;
default:
break;
}
break;
case SUOHA_SAVE_MONEY: /* save money if you want to exit game */
switch (k->code)
{
case KCD_LEFT:
case KCD_OK:
if (isorsaved) //save
SaveMoney();
Suoha_Destroy(win);
break;
case KCD_MNUDOWN:
case KCD_MNURIGHT:
if (isorsaved)
isorsaved=0;
else
isorsaved=1;
DisplayDialog(isorsaved);
break;
case KCD_MNUUP:
case KCD_MNULEFT:
if (isorsaved)
isorsaved=0;
else
isorsaved=1;
DisplayDialog(isorsaved);
break;
case KCD_RIGHT:
case KCD_HUP:
win_states = SUOHA_OPP_SELECT;
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, focus_opp);
break;
}
break;
case SUOHA_MAIN_WINDOW: /* main window of playing */
if (isInteracting) /* don't repond to player's input, */
break;
if ((mainwin_states & SUOHA_ISACTING) ||
(mainwin_states & SUOHA_ISSTAKING))
{
switch (k->code)
{
case KCD_MNUUP: //find pre focus
PreFocus();
break;
case KCD_MNUDOWN: //fine next focus
NextFocus();
break;
case KCD_LEFT: //select the item
case KCD_OK:
SelectFocusItems();
break;
case KCD_HUP:
case KCD_RIGHT:
if (mainwin_states & SUOHA_ISACTING) /* mainwin_states equal to acting */
{
FangQi();
mainwin_focus = (T_SUOHA_MAINWIN_FOCUSTHINGS *)&computercards[0];
}
if (mainwin_states & SUOHA_ISSTAKING) /* mainwin_states is want to staking */
{
Display_Actions();
mainwin_focus = &playeractions[0];
Display_Focus();
for (i=1; i<=3; i++)
{
playeractions[i].thingtype = ACTIONS;
playeractions[i].isenabled = 1;
}
if (c_Cards[curr_CardTh-1]==CompareTwo(p_Cards[curr_CardTh-1], c_Cards[curr_CardTh-1]))
{
playeractions[2].isenabled = 1;
} else
playeractions[2].isenabled = 0;
mainwin_states = (mainwin_states&~SUOHA_ISSTAKING) | SUOHA_ISACTING;
}
break;
default:
break;
}
} else if ( mainwin_states & SUOHA_ISCHECKING )
{
switch (k->code)
{
case KCD_LEFT:
case KCD_OK:
case KCD_HUP:
case KCD_RIGHT: //cancel to main window, and must redraw the items in the main window
mainwin_states = pre_mainwin_states;
RedrawMainWin();
break;
default:
break;
}
} else if (mainwin_states & SUOHA_ISENDING)
{
switch (k->code)
{
case KCD_LEFT:
case KCD_OK:
case KCD_RIGHT:
case KCD_HUP:
EndOne();
break;
default:
break;
}
}
break;
case SUOHA_MON_PUB: //publish the money of player and opponent after one case
switch (k->code)
{
case KCD_LEFT: //select to continue
case KCD_OK:
//generate the result of button to be selected
dspl_Enable(0);
DrawButton(LEFT_B1, TOP_B1, 1);
mfwSleep(100);
DrawButton(LEFT_B1, TOP_B1, 0);
dspl_TextOut(LEFT_B1, TOP_B1+POSITON_TXT, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *)jixu);
dspl_Enable(1);
if (oppmoney[focus_opp-1]>=100 && p_M>=100) //the opponent has money!!
{
Play_Start();
} else
{
Opponent_Select_init();
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, focus_opp); //zhangzg 08/14/2002
}
break;
case KCD_HUP:
case KCD_RIGHT: //select to quit to .......
//generate the result of button to be selected
dspl_Enable(0);
DrawButton(LEFT_B2, TOP_B2, 1);
mfwSleep(100);
DrawButton(LEFT_B2, TOP_B2, 0);
dspl_TextOut(LEFT_B2, TOP_B2+POSITON_TXT, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *)fanhui);
dspl_Enable(1);
if (Opponent_Select_init()) //init the focus_opp = 1
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, focus_opp);
break;
default:
break;
}
break;
default:
break;
}
return MFW_EVENT_CONSUMED;
}
static int Suoha_Tim_Cb(MfwEvt e, MfwTim *t)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_Suoha* data = (T_Suoha *)win_data->user;
// static int i=animation_i, j=animation_j, k=animation_k;
timStop(data->tim);
if (winIsFocussed(data->win)==0)
winfocusout=1;
else
winfocusout=0;
switch (win_states)
{
case SUOHA_START_ANI: /* beginning of the game , show animation first */
if (winfocusout==1) /* at the time of show animation , win focus out */
{
animation_i = animation_j = animation_k = 0;
Opponent_Select_init();
return MFW_EVENT_CONSUMED;
}
/*
* draw a card up , and draw a card down , and on
*/
switch (time_ani_state) /* anmation beginning */
{
case TIMER_START_ANI_PIC2:
dspl_BitBlt(48, 65, 24, 30, 0, (void *)suoha_startpic2, DSPL_BMPCOPY);
time_ani_state = TIMER_START_ANI_EXTEND; /* change time_ani_state mode TIMER_START_ANI_EXTEND */
timStart(data->tim);
break;
case TIMER_START_ANI_EXTEND:
if (animation_i<10)
{
dspl_BitBlt(2+animation_i*5, 55, 38, 51, 0, (void *)cardback, DSPL_BMPCOPY);
DrawHand(2+5*animation_i+15, 55+20);
animation_i++;
} else
{
dspl_ClearAll();
dspl_BitBlt(80, 55, 38, 50, 0, (void *)cardback, DSPL_BMPCOPY);
time_ani_state = TIMER_START_ANI_ONEUP;/* change time_ani_state mode TIMER_START_ANI_ONEUP */
}
timStart(data->tim);
break;
case TIMER_START_ANI_ONEDOWN:
if (animation_k<=4)
{
dspl_BitBlt(38, 56, 38, 51, 0, (void *)cardback, DSPL_BMPCOPY);
DrawHand(38+15, 56+20);
time_ani_state = TIMER_START_ANI_UP; /* change time_ani_state mode TIMER_START_ANI_UP */
timStart(data->tim);
}
break;
case TIMER_START_ANI_ONEUP:
if (animation_j<=4)
{
dspl_BitBlt(38, 52, 38, 51, 0, (void *)cardback, DSPL_BMPCOPY);
DrawHand(38+15, 52+20);
time_ani_state = TIMER_START_ANI_DOWN;/* change time_ani_state mode TIMER_START_ANI_DOWN */
timStart(data->tim);
}
break;
case TIMER_START_ANI_UP:
if (animation_k<=4) /* animation hasn't end */
{
dspl_fill_rectangle(37, 54, 79, 107);
dspl_BitBlt(animation_k*EXPOSED_WIDTH_CARD, 0, 38, 51, 0, (void *)cardback, DSPL_BMPCOPY);
animation_k++;
time_ani_state = TIMER_START_ANI_ONEUP;/* change time_ani_state mode TIMER_START_ANI_ONEUP */
}
if (animation_k==5) /* animation show over , we should display oppnent */
{
animation_i = animation_j = animation_k = 0; /* reinitialize */
win_states = SUOHA_OPP_SELECT;
}
timStart(data->tim);
break;
case TIMER_START_ANI_DOWN:
if (animation_j<=4)
{
dspl_fill_rectangle(37, 50, 79, 104);
dspl_BitBlt(animation_j*EXPOSED_WIDTH_CARD, 109, 38, 51, 0, (void *)cardback, DSPL_BMPCOPY);
animation_j++;
time_ani_state = TIMER_START_ANI_ONEDOWN;/* change time_ani_state mode TIMER_START_ANI_ONEDOWN */
timStart(data->tim);
}
break;
default:
break;
}
break;
/*It's only for test!!!*/
case SUOHA_OPP_SELECT:
if (winfocusout==0) /* win focus on suoha' winhdr */
{
Opponent_Select_init();
Suoha_Display_Opponent();
DisplayMMFigure(focus_opp, 1);
}
break;
case SUOHA_MAIN_WINDOW:
if (winfocusout==1) /* if win has focused out we need start timer */
{
data->timNeedStart=1;
return MFW_EVENT_CONSUMED;
} else
data->timNeedStart=0;
switch (time_state)
{
case TIMER_TCOMPUTER: /* it's computer's turn and player could do nothing */
ComputerAction(curr_CardTh, turnPlayerorComputer);
break;
case TIMER_TPLAYER: /* it's player's turn and player can do anything */
//display "请玩家下注!"
Display_InteractiveStr((char *)wanjiaqing, (char *)wanjiaxiazhu, 0);
isInteracting = 0;//can respond to player's input
break;
case TIMER_INTERACTIVE: /* player or computer follow and need to send card */
Interactive();
break;
case TIMER_FANGQI: /* player or computers didn't want to follow */
EndOne();
break;
case TIMER_QUANSUO: /* if player select QUANSUO action */
Display_InteractiveStr((char *)duishoukaolv, (char *)kaolv, 0);
time_state = TIMER_TCOMPUTER;
timStart(data->tim);
break;
default:
break;
}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -