feat(MCU课设): 增加菜单确认跳转逻辑
This commit is contained in:
parent
5a7be07450
commit
5ef12a7ecc
3 changed files with 498 additions and 445 deletions
File diff suppressed because it is too large
Load diff
|
@ -4,4 +4,5 @@
|
|||
void drawNAME();
|
||||
void drawNUMBER();
|
||||
void drawMAINMENU(unsigned char);
|
||||
void drawBLOCK();
|
||||
#endif
|
|
@ -4,21 +4,22 @@
|
|||
#include "draw.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Menu M_STARTUP;
|
||||
Menu M_MAINMENU;//主菜单
|
||||
Menu M_PLAYMODE1; //俄罗斯方块
|
||||
|
||||
Menu M_BLOCK; //俄罗斯方块
|
||||
Menu M_BALL; //弹球
|
||||
|
||||
|
||||
|
||||
Menu* NOW; //当前菜单指针
|
||||
Menu* LAST = NULL; //上一个状态的菜单
|
||||
|
||||
enum OPR opr = idle;
|
||||
enum OPR opr = idle;
|
||||
static unsigned char local[10] = {0};
|
||||
|
||||
|
||||
//初始菜单
|
||||
//初始化显示
|
||||
void m_startup(struct _menu* this)
|
||||
{
|
||||
|
||||
|
@ -32,7 +33,7 @@ void m_startup(struct _menu* this)
|
|||
drawNUMBER(); //绘制学号
|
||||
}
|
||||
|
||||
if(opr == confirm)
|
||||
if(opr == right)
|
||||
{
|
||||
opr = idle;
|
||||
NOW = this->n; //转向下一菜单
|
||||
|
@ -41,11 +42,11 @@ void m_startup(struct _menu* this)
|
|||
|
||||
}
|
||||
|
||||
//主菜单
|
||||
void m_mainmenu(struct _menu* this)
|
||||
{
|
||||
if(LAST != &M_MAINMENU)
|
||||
{
|
||||
local[0] = 0;
|
||||
LAST = &M_MAINMENU;
|
||||
drawMAINMENU(local[0]);
|
||||
}
|
||||
|
@ -55,20 +56,52 @@ void m_mainmenu(struct _menu* this)
|
|||
local[0]++;
|
||||
if(local[0] > 3)
|
||||
local[0] = 3;
|
||||
|
||||
opr = idle;
|
||||
drawMAINMENU(local[0]);
|
||||
}
|
||||
if(opr == left)
|
||||
{
|
||||
if(local[0] != 0)
|
||||
local[0]--;
|
||||
}
|
||||
if(opr != idle)
|
||||
{
|
||||
|
||||
opr = idle;
|
||||
drawMAINMENU(local[0]);
|
||||
}
|
||||
if(opr == confirm)
|
||||
{
|
||||
|
||||
switch(local[0])
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
NOW = &M_BLOCK; //转向下一菜单
|
||||
break;
|
||||
case 2:
|
||||
NOW = &M_BALL; //转向下一菜单
|
||||
break;
|
||||
case 3:
|
||||
NOW = &M_STARTUP; //转向下一菜单
|
||||
break;
|
||||
}
|
||||
|
||||
local[0]=0;
|
||||
clear();
|
||||
opr = idle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//方块游戏
|
||||
void m_block(struct _menu* this)
|
||||
{
|
||||
if(LAST != &M_MAINMENU)
|
||||
{
|
||||
LAST = &M_MAINMENU;
|
||||
drawBLOCK();
|
||||
}
|
||||
}
|
||||
void menuInit()
|
||||
{
|
||||
M_STARTUP.n = &M_MAINMENU;
|
||||
|
|
Reference in a new issue