00001
00002
00004 #include "revolt.h"
00005 #include "TypeDefs.h"
00006 #include "text.h"
00007 #include "input.h"
00008
00009 #include "Menu.h"
00010 #include "MenuData.h"
00011 #include "MenuText.h"
00012 #include "TitleScreen.h"
00013
00014 void GoFront(void);
00015 extern void (*Event)(void);
00016
00017
00021
00025
00027
00029 void MenuInit(t_Menu *pMenu, t_Menu *pParentMenu)
00030 {
00031
00032 if ((int)pParentMenu != -1)
00033 pMenu->pParentMenu = pParentMenu;
00034
00035
00036 if (pMenu->iMenuItemStart >= 0)
00037 {
00038 pMenu->pMenuItemCur = pMenu->pMenuItems[pMenu->iMenuItemStart];
00039 }
00040 else
00041 {
00042 if (pMenu->pMenuItemCur == NULL)
00043 pMenu->pMenuItemCur = pMenu->pMenuItems[0];
00044 }
00045
00046
00047 if (pMenu->StartUpFunc)
00048 pMenu->StartUpFunc(pMenu);
00049 }
00050
00051
00053
00055 t_Menu *MenuProcess(t_Menu *pMenu)
00056 {
00057 int flag;
00058 int index;
00059
00060
00061 if (pMenu->StartLoopFunc)
00062 {
00063 flag = pMenu->StartLoopFunc(pMenu);
00064 }
00065
00066
00067
00068 if (Keys[DIK_ESCAPE] && !LastKeys[DIK_ESCAPE])
00069 {
00070 if (pMenu->pParentMenu)
00071 {
00072 pMenu = pMenu->pParentMenu;
00073 MenuInit(pMenu, (t_Menu*)-1);
00074 return pMenu;
00075 }
00076 else
00077 {
00078
00079 return NULL;
00080 }
00081 }
00082
00083
00084
00085 index = -1;
00086 if (Keys[DIK_UP] && !LastKeys[DIK_UP])
00087 index = 0;
00088 else if (Keys[DIK_DOWN] && !LastKeys[DIK_DOWN])
00089 index = 1;
00090 else if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT])
00091 index = 2;
00092 else if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT])
00093 index = 3;
00094
00095 if (index >= 0)
00096 {
00097
00098 if (pMenu->pMenuItemCur->Function[index])
00099 pMenu->pMenuItemCur->Function[index](pMenu);
00100
00101
00102 if (pMenu->pMenuItemCur->pSelectMenuItem[index])
00103 pMenu->pMenuItemCur = pMenu->pMenuItemCur->pSelectMenuItem[index];
00104 }
00105
00106
00107
00108 if (Keys[DIK_RETURN] && !LastKeys[DIK_RETURN])
00109 {
00110 if (pMenu->pMenuItemCur->pSelectMenu)
00111 {
00112 MenuInit(pMenu->pMenuItemCur->pSelectMenu, pMenu);
00113 pMenu = pMenu->pMenuItemCur->pSelectMenu;
00114 return pMenu;
00115 }
00116 }
00117
00118
00119
00120 return pMenu;
00121 }
00122
00124
00126 void MenuRender(t_Menu *pMenu)
00127 {
00128 t_MenuItem **pMenuItemList;
00129 t_MenuItem *pMenuItem;
00130 int flags;
00131
00132 pMenuItemList = pMenu->pMenuItems;
00133 while (*pMenuItemList)
00134 {
00135
00136 pMenuItem = *pMenuItemList;
00137
00138
00139 flags = 0;
00140 if (pMenuItem == pMenu->pMenuItemCur)
00141 flags |= MENUITEM_HILIGHT;
00142
00143 MenuItemRender(pMenuItem, flags);
00144
00145
00146 pMenuItemList++;
00147 }
00148 }
00149
00150
00154
00158 void MenuItemRender(t_MenuItem *pMenuItem, int flags)
00159 {
00160 if (flags & MENUITEM_HILIGHT)
00161 DumpText(pMenuItem->textX,pMenuItem->textY, 12,16, 0x80C0FF, pMenuItem->pText);
00162 else
00163 DumpText(pMenuItem->textX,pMenuItem->textY, 12,16, 0x808080, pMenuItem->pText);
00164 }
00165
00166
00167
00169
00171 void DecLightPower(t_Menu* pMenu)
00172 {
00173 gLight[0].power -= 1;
00174 }
00175
00176 void IncLightPower(t_Menu* pMenu)
00177 {
00178 gLight[0].power += 1;
00179 if (gLight[0].power < 1)
00180 gLight[0].power = 1;
00181 }
00182
00183 void DecLightStrength(t_Menu* pMenu)
00184 {
00185 gLight[0].strength -= 10;
00186 }
00187
00188 void IncLightStrength(t_Menu* pMenu)
00189 {
00190 gLight[0].strength += 10;
00191 }
00192