[Scummvm-git-logs] scummvm master -> de88b06b3adc7cead6cd6136c4c2da74ad904bf2
dreammaster
noreply at scummvm.org
Thu Feb 13 05:35:44 UTC 2025
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e644c71ac2 M4: RIDDLE: Fix unused local warning
34e46b3bfd M4: RIDDLE: Refactor gui element structures to C++ hierarchy
de8faee2fc M4: RIDDLE: Move dialog gui functions into guiMenu class
05a0941d2d M4: BURGER: Move button methods to menuItemButton class
de88b06b3a M4: RIDDLE: Add remaining buttons to Game Menu
Commit: e644c71ac2841ee64a9e588838c0fb97bd020e0d
https://github.com/scummvm/scummvm/commit/e644c71ac2841ee64a9e588838c0fb97bd020e0d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-12T18:12:22-08:00
Commit Message:
M4: RIDDLE: Fix unused local warning
Changed paths:
engines/m4/platform/sound/midi.cpp
diff --git a/engines/m4/platform/sound/midi.cpp b/engines/m4/platform/sound/midi.cpp
index 70a204859a9..1402a57541c 100644
--- a/engines/m4/platform/sound/midi.cpp
+++ b/engines/m4/platform/sound/midi.cpp
@@ -55,8 +55,9 @@ void Midi::midi_play(const char *name, int volume, int loop, int trigger, int ro
error("Could not find music - %s", fileName.c_str());
HLock(workHandle);
- byte *pSrc = (byte *)*workHandle;
#ifdef TODO
+ byte *pSrc = (byte *)*workHandle;
+
MidiParser *parser = MidiParser::createParser_SMF();
bool loaded = parser->loadMusic(pSrc, assetSize);
Commit: 34e46b3bfd5404262cfdb14ecae400a0e7284bbb
https://github.com/scummvm/scummvm/commit/34e46b3bfd5404262cfdb14ecae400a0e7284bbb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-12T19:27:31-08:00
Commit Message:
M4: RIDDLE: Refactor gui element structures to C++ hierarchy
Changed paths:
engines/m4/burger/gui/game_menu.cpp
engines/m4/burger/gui/game_menu.h
engines/m4/gui/gui_menu.cpp
engines/m4/gui/gui_menu.h
diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index 885bf324836..e720435e7ea 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -282,36 +282,29 @@ void gui_DrawSprite(Sprite *mySprite, Buffer *myBuff, int32 x, int32 y) {
}
-void item_Destroy(void *theItem) {
- menuItem *myItem = (menuItem *)theItem;
-
+void item_Destroy(menuItem *theItem) {
// Verify params
- if (!myItem) {
+ if (!theItem) {
return;
}
- if (myItem->background) {
- delete myItem->background;
+ if (theItem->background) {
+ delete theItem->background;
}
- if (myItem->itemInfo) {
- mem_free((void *)myItem->itemInfo);
- }
- mem_free((void *)myItem);
+ delete theItem;
}
//------------------------------- MESSAGE MENU ITEM ---------------------------------//
-void menu_DrawMsg(void *theItem, void *theMenu, int32 x, int32 y, int32, int32) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
+void menu_DrawMsg(menuItemMsg *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
Buffer *myBuff = nullptr;
Buffer *backgroundBuff = nullptr;
Sprite *mySprite = nullptr;
// Verify params
- if ((!myItem) || (!myItem->itemInfo) || (!myMenu)) {
+ if (!myItem || !myMenu) {
return;
}
@@ -369,9 +362,8 @@ void menu_DrawMsg(void *theItem, void *theMenu, int32 x, int32 y, int32, int32)
}
-menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, bool transparent) {
- menuItem *newItem;
- menuItemMsg *msgInfo;
+menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, bool transparent) {
+ menuItemMsg *newItem;
ScreenContext *myScreen;
int32 status;
@@ -381,9 +373,7 @@ menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int
}
// Allocate a new one
- if ((newItem = (menuItem *)mem_alloc(sizeof(menuItem), "gui menu item")) == nullptr) {
- return nullptr;
- }
+ newItem = new menuItemMsg();
// Initialize the struct
newItem->next = myMenu->itemList;
@@ -393,7 +383,7 @@ menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int
}
myMenu->itemList = newItem;
- newItem->myMenu = (void *)myMenu;
+ newItem->myMenu = myMenu;
newItem->tag = tag;
newItem->x1 = x;
newItem->y1 = y;
@@ -409,20 +399,15 @@ menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int
newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
}
- if ((msgInfo = (menuItemMsg *)mem_alloc(sizeof(menuItemMsg), "menu item message")) == nullptr) {
- return nullptr;
- }
- newItem->itemInfo = (void *)msgInfo;
-
- newItem->redraw = menu_DrawMsg;
- newItem->destroy = item_Destroy;
+ newItem->redraw = (DrawFunction)menu_DrawMsg;
+ newItem->destroy = (DestroyFunction)item_Destroy;
newItem->itemEventHandler = nullptr;
// Draw the message in now
- (newItem->redraw)(newItem, (void *)myMenu, x, y, 0, 0);
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
// See if the screen is currently visible
- myScreen = vmng_screen_find((void *)myMenu, &status);
+ myScreen = vmng_screen_find(myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
@@ -455,17 +440,14 @@ enum button_types {
};
-void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int32) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItemButton *myButton = nullptr;
+void menu_DrawButton(menuItemButton *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
Buffer *myBuff = nullptr;
Buffer *backgroundBuff = nullptr;
Sprite *mySprite = nullptr;
char tempStr[32];
// Verify params
- if ((!myItem) || (!myItem->itemInfo) || (!myMenu)) {
+ if (!myItem || !myMenu) {
return;
}
@@ -480,12 +462,10 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
}
}
- // Get the button info and select the sprite
- myButton = (menuItemButton *)myItem->itemInfo;
-
- switch (myButton->buttonType) {
+ // Select the sprite
+ switch (myItem->buttonType) {
case BTN_TYPE_GM_GENERIC:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[GM_BUTTON_NORM];
break;
@@ -503,7 +483,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_SL_SAVE:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[SL_SAVE_BTN_NORM];
break;
@@ -521,7 +501,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_SL_LOAD:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[SL_LOAD_BTN_NORM];
break;
@@ -539,7 +519,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_SL_TEXT:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_OVER:
font_set_colors(TEXT_COLOR_OVER_SHADOW, TEXT_COLOR_OVER_FOREGROUND, TEXT_COLOR_OVER_HILITE);
// Gr_font_set_color(TEXT_COLOR_OVER);
@@ -565,7 +545,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_SL_CANCEL:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[SL_CANCEL_BTN_NORM];
break;
@@ -583,7 +563,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_OM_DONE:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[OM_DONE_BTN_NORM];
break;
@@ -601,7 +581,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
break;
case BTN_TYPE_OM_CANCEL:
- switch (myButton->itemFlags) {
+ switch (myItem->itemFlags) {
case BTN_STATE_NORM:
mySprite = _GM(menuSprites)[OM_CANCEL_BTN_NORM];
break;
@@ -635,13 +615,13 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
gui_DrawSprite(mySprite, myBuff, x, y);
// If the button is a textbutton, write in the text
- if ((myButton->buttonType == BTN_TYPE_SL_TEXT) && (myButton->prompt)) {
+ if ((myItem->buttonType == BTN_TYPE_SL_TEXT) && (myItem->prompt)) {
// Write in the special tag
Common::sprintf_s(tempStr, 32, "%02d", myItem->tag - 1000 + _GM(firstSlotIndex));
gr_font_set(_GM(menuFont));
gr_font_write(myBuff, tempStr, x + 4, y + 1, 0, -1);
- gr_font_write(myBuff, myButton->prompt, x + 26, y + 1, 0, -1);
+ gr_font_write(myBuff, myItem->prompt, x + 26, y + 1, 0, -1);
}
// Release the menu buffer
@@ -649,9 +629,7 @@ void menu_DrawButton(void *theItem, void *theMenu, int32 x, int32 y, int32, int3
}
-bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- menuItem *myItem = (menuItem *)theItem;
- menuItemButton *myButton;
+bool button_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
bool redrawItem, execCallback, handled;
ScreenContext *myScreen;
int32 status;
@@ -660,16 +638,15 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
menuItem *tempItem;
// Verify params
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem) {
return false;
}
- myButton = (menuItemButton *)myItem->itemInfo;
if (!(eventType == EVENT_MOUSE)) {
return false;
}
- if (myButton->itemFlags == BTN_STATE_GREY) {
+ if (myItem->itemFlags == BTN_STATE_GREY) {
return false;
}
@@ -681,13 +658,13 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
case _ME_L_click:
case _ME_doubleclick:
if (menu_CursorInsideItem(myItem, x, y)) {
- myButton->itemFlags = BTN_STATE_PRESS;
- *currItem = theItem;
+ myItem->itemFlags = BTN_STATE_PRESS;
+ *currItem = myItem;
redrawItem = true;
} else {
*currItem = nullptr;
- if (myButton->itemFlags != BTN_STATE_NORM) {
- myButton->itemFlags = BTN_STATE_NORM;
+ if (myItem->itemFlags != BTN_STATE_NORM) {
+ myItem->itemFlags = BTN_STATE_NORM;
redrawItem = true;
}
}
@@ -699,13 +676,13 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
return true;
}
if (menu_CursorInsideItem(myItem, x, y)) {
- if (myButton->itemFlags != BTN_STATE_PRESS) {
- myButton->itemFlags = BTN_STATE_PRESS;
+ if (myItem->itemFlags != BTN_STATE_PRESS) {
+ myItem->itemFlags = BTN_STATE_PRESS;
redrawItem = true;
}
} else {
- if (myButton->itemFlags != BTN_STATE_OVER) {
- myButton->itemFlags = BTN_STATE_OVER;
+ if (myItem->itemFlags != BTN_STATE_OVER) {
+ myItem->itemFlags = BTN_STATE_OVER;
redrawItem = true;
}
}
@@ -717,13 +694,13 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
if (*currItem) {
execCallback = true;
} else {
- *currItem = theItem;
+ *currItem = myItem;
}
- myButton->itemFlags = BTN_STATE_OVER;
+ myItem->itemFlags = BTN_STATE_OVER;
redrawItem = true;
} else {
*currItem = nullptr;
- myButton->itemFlags = BTN_STATE_NORM;
+ myItem->itemFlags = BTN_STATE_NORM;
redrawItem = true;
handled = false;
}
@@ -731,15 +708,15 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
case _ME_move:
if (menu_CursorInsideItem(myItem, x, y)) {
- *currItem = theItem;
- if (myButton->itemFlags != BTN_STATE_OVER) {
- myButton->itemFlags = BTN_STATE_OVER;
+ *currItem = myItem;
+ if (myItem->itemFlags != BTN_STATE_OVER) {
+ myItem->itemFlags = BTN_STATE_OVER;
redrawItem = true;
}
} else {
*currItem = nullptr;
- if (myButton->itemFlags != BTN_STATE_NORM) {
- myButton->itemFlags = BTN_STATE_NORM;
+ if (myItem->itemFlags != BTN_STATE_NORM) {
+ myItem->itemFlags = BTN_STATE_NORM;
redrawItem = true;
handled = false;
}
@@ -753,8 +730,8 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
// See if we need to redraw the button
if (redrawItem) {
- (myItem->redraw)((void *)myItem, (void *)myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
@@ -768,10 +745,10 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
currTag = myItem->tag;
buttonClosesDialog = false;
- (myItem->callback)((void *)myItem, (void *)myItem->myMenu);
+ (myItem->callback)((void *)myItem, myItem->myMenu);
status = 0;
- myScreen = buttonClosesDialog ? nullptr : vmng_screen_find((void *)myItem->myMenu, &status);
+ myScreen = buttonClosesDialog ? nullptr : vmng_screen_find(myItem->myMenu, &status);
if ((!myScreen) || (status != SCRN_ACTIVE)) {
*currItem = nullptr;
@@ -787,10 +764,9 @@ bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
}
-menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback, int32 buttonType,
+menuItemButton *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback, int32 buttonType,
bool greyed, bool transparent, const char *prompt, ItemHandlerFunction i_handler) {
- menuItem *newItem;
- menuItemButton *buttonInfo;
+ menuItemButton *newItem;
ScreenContext *myScreen;
int32 status;
@@ -800,9 +776,7 @@ menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
// Allocate a new one
- if ((newItem = (menuItem *)mem_alloc(sizeof(menuItem), "gui menu item")) == nullptr) {
- return nullptr;
- }
+ newItem = new menuItemButton();
// Initialize the struct
newItem->next = myMenu->itemList;
@@ -812,7 +786,7 @@ menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
myMenu->itemList = newItem;
- newItem->myMenu = (void *)myMenu;
+ newItem->myMenu = myMenu;
newItem->tag = tag;
newItem->x1 = x;
newItem->y1 = y;
@@ -828,31 +802,26 @@ menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
}
- if ((buttonInfo = (menuItemButton *)mem_alloc(sizeof(menuItemButton), "menu item button")) == nullptr) {
- return nullptr;
- }
if (greyed) {
- buttonInfo->itemFlags = BTN_STATE_GREY;
+ newItem->itemFlags = BTN_STATE_GREY;
} else {
- buttonInfo->itemFlags = BTN_STATE_NORM;
+ newItem->itemFlags = BTN_STATE_NORM;
}
- buttonInfo->buttonType = buttonType;
+ newItem->buttonType = buttonType;
// Note: prompt is not duplicated, therefore, make sure the name is stored in non-volatile memory
- buttonInfo->prompt = prompt;
- buttonInfo->specialTag = tag - 1000;
-
- newItem->itemInfo = (void *)buttonInfo;
+ newItem->prompt = prompt;
+ newItem->specialTag = tag - 1000;
- newItem->redraw = menu_DrawButton;
- newItem->destroy = item_Destroy;
+ newItem->redraw = (DrawFunction)menu_DrawButton;
+ newItem->destroy = (DestroyFunction)item_Destroy;
newItem->itemEventHandler = i_handler;
// Draw the button in now
- (newItem->redraw)(newItem, (void *)myMenu, x, y, 0, 0);
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
// See if the screen is currently visible
- myScreen = vmng_screen_find((void *)myMenu, &status);
+ myScreen = vmng_screen_find(myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
@@ -862,43 +831,31 @@ menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
-void menu_DisableButton(menuItem *myItem, int32 tag, guiMenu *myMenu) {
- menuItemButton *myButton;
-
+void menu_DisableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return;
- }
- if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
- }
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
+ myItem = (menuItemButton *)menu_GetItem(tag, myMenu);
+ if (!myItem)
return;
- }
- myButton = (menuItemButton *)myItem->itemInfo;
- myButton->itemFlags = BTN_STATE_GREY;
+ myItem->itemFlags = BTN_STATE_GREY;
}
-void menu_EnableButton(menuItem *myItem, int32 tag, guiMenu *myMenu) {
- menuItemButton *myButton;
-
+void menu_EnableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return;
- }
- if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
- }
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
+ myItem = (menuItemButton *)menu_GetItem(tag, myMenu);
+ if (!myItem)
return;
- }
- myButton = (menuItemButton *)myItem->itemInfo;
- myButton->itemFlags = BTN_STATE_NORM;
+ myItem->itemFlags = BTN_STATE_NORM;
}
@@ -911,18 +868,14 @@ enum {
};
-void menu_DrawHSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int32) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItemHSlider *mySlider = nullptr;
+void menu_DrawHSlider(menuItemHSlider *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
Buffer *myBuff = nullptr;
Buffer *backgroundBuff = nullptr;
Sprite *mySprite = nullptr;
// Verify params
- if ((!myItem) || (!myItem->itemInfo) || (!myMenu)) {
+ if (!myItem || !myMenu)
return;
- }
// If the item is marked transparent, get the background buffer
if (myItem->transparent) {
@@ -948,8 +901,7 @@ void menu_DrawHSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
}
// Get the slider info and select the thumb sprite
- mySlider = (menuItemHSlider *)myItem->itemInfo;
- switch (mySlider->itemFlags) {
+ switch (myItem->itemFlags) {
case H_THUMB_OVER:
mySprite = _GM(menuSprites)[OM_SLIDER_BTN_OVER];
break;
@@ -963,22 +915,20 @@ void menu_DrawHSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
}
// Fill in everything left of the thumb with a hilite color
- if (mySlider->thumbX > 2) {
+ if (myItem->thumbX > 2) {
gr_color_set(SLIDER_BAR_COLOR);
- gr_buffer_rect_fill(myBuff, myItem->x1 + 3, myItem->y1 + 9, mySlider->thumbX, mySlider->thumbH - 18);
+ gr_buffer_rect_fill(myBuff, myItem->x1 + 3, myItem->y1 + 9, myItem->thumbX, myItem->thumbH - 18);
}
// Draw in the thumb
- gui_DrawSprite(mySprite, myBuff, myItem->x1 + mySlider->thumbX, myItem->y1);
+ gui_DrawSprite(mySprite, myBuff, myItem->x1 + myItem->thumbX, myItem->y1);
// Release the menu buffer
myMenu->menuBuffer->release();
}
-bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- menuItem *myItem = (menuItem *)theItem;
- menuItemHSlider *mySlider;
+bool hslider_Handler(menuItemHSlider *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
bool redrawItem, execCallback, handled;
ScreenContext *myScreen;
int32 status;
@@ -987,10 +937,8 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
static int32 movingX;
// Verify params
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
return false;
- }
- mySlider = (menuItemHSlider *)myItem->itemInfo;
if (!(eventType == EVENT_MOUSE)) {
return false;
@@ -1003,17 +951,16 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
switch (event) {
case _ME_L_click:
case _ME_doubleclick:
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= mySlider->thumbX) &&
- (x - myItem->x1 <= mySlider->thumbX + mySlider->thumbW - 1)) {
- // digi_play(inv_click_snd, 2, 255, -1, inv_click_snd_room_lock);
- mySlider->itemFlags = H_THUMB_PRESS;
+ if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ (x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
+ myItem->itemFlags = H_THUMB_PRESS;
movingFlag = true;
movingX = x;
- *currItem = theItem;
+ *currItem = myItem;
redrawItem = true;
} else {
*currItem = nullptr;
- mySlider->itemFlags = 0;
+ myItem->itemFlags = 0;
redrawItem = true;
}
break;
@@ -1025,27 +972,27 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
}
if (movingFlag) {
if (x < movingX) {
- deltaSlide = imath_min(mySlider->thumbX, movingX - x);
+ deltaSlide = imath_min(myItem->thumbX, movingX - x);
if (deltaSlide > 0) {
- mySlider->thumbX -= deltaSlide;
+ myItem->thumbX -= deltaSlide;
redrawItem = true;
- mySlider->percent = mySlider->thumbX * 100 / mySlider->maxThumbX;
+ myItem->percent = myItem->thumbX * 100 / myItem->maxThumbX;
execCallback = true;
}
} else if (x > movingX) {
- deltaSlide = imath_min(mySlider->maxThumbX - mySlider->thumbX, x - movingX);
+ deltaSlide = imath_min(myItem->maxThumbX - myItem->thumbX, x - movingX);
if (deltaSlide > 0) {
- mySlider->thumbX += deltaSlide;
+ myItem->thumbX += deltaSlide;
redrawItem = true;
- mySlider->percent = mySlider->thumbX * 100 / mySlider->maxThumbX;
+ myItem->percent = myItem->thumbX * 100 / myItem->maxThumbX;
execCallback = true;
}
}
movingX = x;
- if (movingX < (mySlider->thumbX + myItem->x1)) {
- movingX = mySlider->thumbX + myItem->x1;
- } else if (movingX > (mySlider->thumbX + mySlider->thumbW - 1 + myItem->x1)) {
- movingX = mySlider->thumbX + mySlider->thumbW - 1 + myItem->x1;
+ if (movingX < (myItem->thumbX + myItem->x1)) {
+ movingX = myItem->thumbX + myItem->x1;
+ } else if (movingX > (myItem->thumbX + myItem->thumbW - 1 + myItem->x1)) {
+ movingX = myItem->thumbX + myItem->thumbW - 1 + myItem->x1;
}
} else {
*currItem = nullptr;
@@ -1058,12 +1005,12 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
return true;
}
movingFlag = false;
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= mySlider->thumbX) &&
- (x - myItem->x1 <= mySlider->thumbX + mySlider->thumbW - 1)) {
- mySlider->itemFlags = H_THUMB_OVER;
- *currItem = theItem;
+ if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ (x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
+ myItem->itemFlags = H_THUMB_OVER;
+ *currItem = myItem;
} else {
- mySlider->itemFlags = H_THUMB_NORM;
+ myItem->itemFlags = H_THUMB_NORM;
*currItem = nullptr;
}
redrawItem = true;
@@ -1071,16 +1018,16 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
break;
case _ME_move:
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= mySlider->thumbX) &&
- (x - myItem->x1 <= mySlider->thumbX + mySlider->thumbW - 1)) {
- if (mySlider->itemFlags != H_THUMB_OVER) {
- mySlider->itemFlags = H_THUMB_OVER;
- *currItem = theItem;
+ if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ (x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
+ if (myItem->itemFlags != H_THUMB_OVER) {
+ myItem->itemFlags = H_THUMB_OVER;
+ *currItem = myItem;
redrawItem = true;
}
} else {
- if (mySlider->itemFlags != H_THUMB_NORM) {
- mySlider->itemFlags = H_THUMB_NORM;
+ if (myItem->itemFlags != H_THUMB_NORM) {
+ myItem->itemFlags = H_THUMB_NORM;
*currItem = nullptr;
redrawItem = true;
handled = false;
@@ -1095,8 +1042,8 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
// See if we need to redraw the hslider
if (redrawItem) {
- (myItem->redraw)((void *)myItem, (void *)myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
@@ -1105,8 +1052,8 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
// See if we need to call the callback function
if (execCallback && myItem->callback) {
- (myItem->callback)((void *)myItem, (void *)myItem->myMenu);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->callback)((void *)myItem, myItem->myMenu);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if ((!myScreen) || (status != SCRN_ACTIVE)) {
*currItem = nullptr;
}
@@ -1116,10 +1063,9 @@ bool hslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
}
-menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
+menuItemHSlider *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
int32 initPercent, CALLBACK callback, bool transparent) {
- menuItem *newItem;
- menuItemHSlider *sliderInfo;
+ menuItemHSlider *newItem;
ScreenContext *myScreen;
int32 status;
@@ -1129,9 +1075,7 @@ menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
// Allocate a new one
- if ((newItem = (menuItem *)mem_alloc(sizeof(menuItem), "gui menu item")) == nullptr) {
- return nullptr;
- }
+ newItem = new menuItemHSlider();
// Initialize the struct
newItem->next = myMenu->itemList;
@@ -1141,7 +1085,7 @@ menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
myMenu->itemList = newItem;
- newItem->myMenu = (void *)myMenu;
+ newItem->myMenu = myMenu;
newItem->tag = tag;
newItem->x1 = x;
newItem->y1 = y;
@@ -1157,16 +1101,11 @@ menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
}
- // Create a new slider
- if ((sliderInfo = (menuItemHSlider *)mem_alloc(sizeof(menuItemHSlider), "menu item hslider")) == nullptr) {
- return nullptr;
- }
-
// Intialize the new slider
- sliderInfo->itemFlags = H_THUMB_NORM;
- sliderInfo->thumbW = _GM(menuSprites)[OM_SLIDER_BTN_NORM]->w;
- sliderInfo->thumbH = _GM(menuSprites)[OM_SLIDER_BTN_NORM]->h;
- sliderInfo->maxThumbX = w - _GM(menuSprites)[OM_SLIDER_BTN_NORM]->w;
+ newItem->itemFlags = H_THUMB_NORM;
+ newItem->thumbW = _GM(menuSprites)[OM_SLIDER_BTN_NORM]->w;
+ newItem->thumbH = _GM(menuSprites)[OM_SLIDER_BTN_NORM]->h;
+ newItem->maxThumbX = w - _GM(menuSprites)[OM_SLIDER_BTN_NORM]->w;
if (initPercent < 0) {
initPercent = 0;
@@ -1175,20 +1114,18 @@ menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
// Calculate the initial thumbX
- sliderInfo->percent = initPercent;
- sliderInfo->thumbX = initPercent * sliderInfo->maxThumbX / 100;
-
- newItem->itemInfo = (void *)sliderInfo;
+ newItem->percent = initPercent;
+ newItem->thumbX = initPercent * newItem->maxThumbX / 100;
- newItem->redraw = menu_DrawHSlider;
- newItem->destroy = item_Destroy;
- newItem->itemEventHandler = hslider_Handler;
+ newItem->redraw = (DrawFunction)menu_DrawHSlider;
+ newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->itemEventHandler = (ItemHandlerFunction)hslider_Handler;
// Draw the slider in now
- (newItem->redraw)(newItem, (void *)myMenu, x, y, 0, 0);
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
// See if the screen is currently visible
- myScreen = vmng_screen_find((void *)myMenu, &status);
+ myScreen = vmng_screen_find(myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
@@ -1215,10 +1152,7 @@ enum {
};
-void menu_DrawVSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int32) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItemVSlider *myVSlider = nullptr;
+void menu_DrawVSlider(menuItemVSlider *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
Buffer *myBuff = nullptr;
Buffer *backgroundBuff = nullptr;
Sprite *upSprite = nullptr;
@@ -1227,9 +1161,8 @@ void menu_DrawVSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
Sprite *vbarSprite = nullptr;
// Verify params
- if ((!myItem) || (!myItem->itemInfo) || (!myMenu)) {
+ if (!myItem || !myMenu)
return;
- }
// If the item is marked transparent, get the background buffer
if (myItem->transparent) {
@@ -1242,8 +1175,6 @@ void menu_DrawVSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
}
}
- myVSlider = (menuItemVSlider *)myItem->itemInfo;
-
// Get the menu buffer
myBuff = myMenu->menuBuffer->get_buffer();
if (!myBuff) {
@@ -1262,24 +1193,24 @@ void menu_DrawVSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_NORM];
downSprite = _GM(menuSprites)[SL_DOWN_BTN_NORM];
- if ((myVSlider->itemFlags & VS_STATUS) == VS_GREY) {
+ if ((myItem->itemFlags & VS_STATUS) == VS_GREY) {
upSprite = _GM(menuSprites)[SL_UP_BTN_GREY];
thumbSprite = nullptr;
downSprite = _GM(menuSprites)[SL_DOWN_BTN_GREY];
- } else if ((myVSlider->itemFlags & VS_STATUS) == VS_OVER) {
- if ((myVSlider->itemFlags & VS_COMPONENT) == VS_UP) {
+ } else if ((myItem->itemFlags & VS_STATUS) == VS_OVER) {
+ if ((myItem->itemFlags & VS_COMPONENT) == VS_UP) {
upSprite = _GM(menuSprites)[SL_UP_BTN_OVER];
- } else if ((myVSlider->itemFlags & VS_COMPONENT) == VS_THUMB) {
+ } else if ((myItem->itemFlags & VS_COMPONENT) == VS_THUMB) {
thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_OVER];
- } else if ((myVSlider->itemFlags & VS_COMPONENT) == VS_DOWN) {
+ } else if ((myItem->itemFlags & VS_COMPONENT) == VS_DOWN) {
downSprite = _GM(menuSprites)[SL_DOWN_BTN_OVER];
}
- } else if ((myVSlider->itemFlags & VS_STATUS) == VS_PRESS) {
- if ((myVSlider->itemFlags & VS_COMPONENT) == VS_UP) {
+ } else if ((myItem->itemFlags & VS_STATUS) == VS_PRESS) {
+ if ((myItem->itemFlags & VS_COMPONENT) == VS_UP) {
upSprite = _GM(menuSprites)[SL_UP_BTN_PRESS];
- } else if ((myVSlider->itemFlags & VS_COMPONENT) == VS_THUMB) {
+ } else if ((myItem->itemFlags & VS_COMPONENT) == VS_THUMB) {
thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_PRESS];
- } else if ((myVSlider->itemFlags & VS_COMPONENT) == VS_DOWN) {
+ } else if ((myItem->itemFlags & VS_COMPONENT) == VS_DOWN) {
downSprite = _GM(menuSprites)[SL_DOWN_BTN_PRESS];
}
}
@@ -1287,7 +1218,7 @@ void menu_DrawVSlider(void *theItem, void *theMenu, int32 x, int32 y, int32, int
// Draw the sprite comonents
gui_DrawSprite(vbarSprite, myBuff, x, y + upSprite->h);
gui_DrawSprite(upSprite, myBuff, x, y);
- gui_DrawSprite(thumbSprite, myBuff, x, y + myVSlider->thumbY);
+ gui_DrawSprite(thumbSprite, myBuff, x, y + myItem->thumbY);
gui_DrawSprite(downSprite, myBuff, x, y + upSprite->h + vbarSprite->h);
// Release the menu buffer
@@ -1308,9 +1239,7 @@ int32 vslider_WhereIsCursor(menuItemVSlider *myVSlider, int32 y) {
}
}
-bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- menuItem *myItem = (menuItem *)theItem;
- menuItemVSlider *myVSlider;
+bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
bool redrawItem, execCallback, handled;
int32 tempFlags;
ScreenContext *myScreen;
@@ -1322,16 +1251,13 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
static int32 callbackTime;
// Verify params
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
return false;
- }
- if (!(eventType == EVENT_MOUSE)) {
+ if (!(eventType == EVENT_MOUSE))
return false;
- }
- myVSlider = (menuItemVSlider *)myItem->itemInfo;
- if ((myVSlider->itemFlags & VS_STATUS) == VS_GREY) {
+ if ((myItem->itemFlags & VS_STATUS) == VS_GREY) {
*currItem = nullptr;
return false;
}
@@ -1346,22 +1272,22 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
case _ME_doubleclick:
if (menu_CursorInsideItem(myItem, x, y)) {
// digi_play(inv_click_snd, 2, 255, -1, inv_click_snd_room_lock);
- *currItem = theItem;
- tempFlags = vslider_WhereIsCursor(myVSlider, y - myItem->y1);
+ *currItem = myItem;
+ tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if (tempFlags == VS_THUMB) {
movingFlag = true;
movingY = y;
}
if ((tempFlags == VS_PAGE_UP) || (tempFlags == VS_PAGE_DOWN)) {
- myVSlider->itemFlags = tempFlags + VS_NORM;
+ myItem->itemFlags = tempFlags + VS_NORM;
} else {
- myVSlider->itemFlags = tempFlags + VS_PRESS;
+ myItem->itemFlags = tempFlags + VS_PRESS;
redrawItem = true;
}
execCallback = true;
} else {
*currItem = nullptr;
- myVSlider->itemFlags = VS_NORM;
+ myItem->itemFlags = VS_NORM;
redrawItem = true;
}
break;
@@ -1373,52 +1299,52 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
}
if (movingFlag) {
if (y < movingY) {
- deltaSlide = imath_min(myVSlider->thumbY - myVSlider->minThumbY, movingY - y);
+ deltaSlide = imath_min(myItem->thumbY - myItem->minThumbY, movingY - y);
if (deltaSlide > 0) {
- myVSlider->thumbY -= deltaSlide;
- myVSlider->percent = ((myVSlider->thumbY - myVSlider->minThumbY) * 100) /
- (myVSlider->maxThumbY - myVSlider->minThumbY);
+ myItem->thumbY -= deltaSlide;
+ myItem->percent = ((myItem->thumbY - myItem->minThumbY) * 100) /
+ (myItem->maxThumbY - myItem->minThumbY);
redrawItem = true;
execCallback = true;
}
} else if (y > movingY) {
- deltaSlide = imath_min(myVSlider->maxThumbY - myVSlider->thumbY, y - movingY);
+ deltaSlide = imath_min(myItem->maxThumbY - myItem->thumbY, y - movingY);
if (deltaSlide > 0) {
- myVSlider->thumbY += deltaSlide;
- myVSlider->percent = ((myVSlider->thumbY - myVSlider->minThumbY) * 100) /
- (myVSlider->maxThumbY - myVSlider->minThumbY);
+ myItem->thumbY += deltaSlide;
+ myItem->percent = ((myItem->thumbY - myItem->minThumbY) * 100) /
+ (myItem->maxThumbY - myItem->minThumbY);
redrawItem = true;
execCallback = true;
}
}
movingY = y;
- if (movingY < (myVSlider->thumbY + myItem->y1)) {
- movingY = myVSlider->thumbY + myItem->y1;
- } else if (movingY > (myVSlider->thumbY + myVSlider->thumbH - 1 + myItem->y1)) {
- movingY = myVSlider->thumbY + myVSlider->thumbH - 1 + myItem->y1;
+ if (movingY < (myItem->thumbY + myItem->y1)) {
+ movingY = myItem->thumbY + myItem->y1;
+ } else if (movingY > (myItem->thumbY + myItem->thumbH - 1 + myItem->y1)) {
+ movingY = myItem->thumbY + myItem->thumbH - 1 + myItem->y1;
}
} else {
if (menu_CursorInsideItem(myItem, x, y)) {
- tempFlags = vslider_WhereIsCursor(myVSlider, y - myItem->y1);
- if ((myVSlider->itemFlags & VS_COMPONENT) == tempFlags) {
+ tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
+ if ((myItem->itemFlags & VS_COMPONENT) == tempFlags) {
if ((tempFlags != VS_PAGE_UP) && (tempFlags != VS_PAGE_DOWN) &&
- ((myVSlider->itemFlags & VS_STATUS) != VS_PRESS)) {
- myVSlider->itemFlags = tempFlags + VS_PRESS;
+ ((myItem->itemFlags & VS_STATUS) != VS_PRESS)) {
+ myItem->itemFlags = tempFlags + VS_PRESS;
redrawItem = true;
}
if (currTime - callbackTime > 6) {
execCallback = true;
}
} else {
- if ((myVSlider->itemFlags & VS_STATUS) != VS_OVER) {
- myVSlider->itemFlags = (myVSlider->itemFlags & VS_COMPONENT) + VS_OVER;
+ if ((myItem->itemFlags & VS_STATUS) != VS_OVER) {
+ myItem->itemFlags = (myItem->itemFlags & VS_COMPONENT) + VS_OVER;
redrawItem = true;
}
}
execCallback = true;
} else {
- if ((myVSlider->itemFlags & VS_STATUS) != VS_OVER) {
- myVSlider->itemFlags = (myVSlider->itemFlags & VS_COMPONENT) + VS_OVER;
+ if ((myItem->itemFlags & VS_STATUS) != VS_OVER) {
+ myItem->itemFlags = (myItem->itemFlags & VS_COMPONENT) + VS_OVER;
redrawItem = true;
}
}
@@ -1429,15 +1355,15 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
case _ME_doubleclick_release:
movingFlag = false;
if (menu_CursorInsideItem(myItem, x, y)) {
- tempFlags = vslider_WhereIsCursor(myVSlider, y - myItem->y1);
+ tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if ((tempFlags == VS_PAGE_UP) || (tempFlags == VS_PAGE_DOWN)) {
- myVSlider->itemFlags = VS_NORM;
+ myItem->itemFlags = VS_NORM;
} else {
- myVSlider->itemFlags = tempFlags + VS_OVER;
- *currItem = theItem;
+ myItem->itemFlags = tempFlags + VS_OVER;
+ *currItem = myItem;
}
} else {
- myVSlider->itemFlags = VS_NORM;
+ myItem->itemFlags = VS_NORM;
*currItem = nullptr;
}
redrawItem = true;
@@ -1448,20 +1374,20 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
case _ME_move:
if (menu_CursorInsideItem(myItem, x, y)) {
- *currItem = theItem;
- tempFlags = vslider_WhereIsCursor(myVSlider, y - myItem->y1);
- if ((myVSlider->itemFlags & VS_COMPONENT) != tempFlags) {
+ *currItem = myItem;
+ tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
+ if ((myItem->itemFlags & VS_COMPONENT) != tempFlags) {
if ((tempFlags == VS_PAGE_UP) || (tempFlags == VS_PAGE_DOWN)) {
- myVSlider->itemFlags = VS_NORM;
+ myItem->itemFlags = VS_NORM;
} else {
- myVSlider->itemFlags = tempFlags + VS_OVER;
+ myItem->itemFlags = tempFlags + VS_OVER;
}
redrawItem = true;
}
} else {
*currItem = nullptr;
- if (myVSlider->itemFlags != VS_NORM) {
- myVSlider->itemFlags = VS_NORM;
+ if (myItem->itemFlags != VS_NORM) {
+ myItem->itemFlags = VS_NORM;
redrawItem = true;
handled = false;
}
@@ -1474,8 +1400,8 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
return true;
}
if (menu_CursorInsideItem(myItem, x, y)) {
- tempFlags = vslider_WhereIsCursor(myVSlider, y - myItem->y1);
- if ((myVSlider->itemFlags & VS_COMPONENT) == tempFlags) {
+ tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
+ if ((myItem->itemFlags & VS_COMPONENT) == tempFlags) {
if (currTime - callbackTime > 6) {
execCallback = true;
}
@@ -1486,8 +1412,8 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
// See if we need to redraw the vslider
if (redrawItem) {
- (myItem->redraw)((void *)myItem, (void *)myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
@@ -1497,8 +1423,8 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
// See if we need to call the callback function
if (execCallback && myItem->callback) {
callbackTime = currTime;
- (myItem->callback)((void *)myItem, (void *)myItem->myMenu);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->callback)((void *)myItem, myItem->myMenu);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if ((!myScreen) || (status != SCRN_ACTIVE)) {
*currItem = nullptr;
}
@@ -1508,23 +1434,18 @@ bool vslider_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32
}
-menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
- int32 initPercent, CALLBACK callback, bool transparent) {
-
- menuItem *newItem;
- menuItemVSlider *vsliderInfo;
+menuItemVSlider *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
+ int32 initPercent, CALLBACK callback, bool transparent) {
+ menuItemVSlider *newItem;
ScreenContext *myScreen;
int32 status;
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return nullptr;
- }
// Allocate a new one
- if ((newItem = (menuItem *)mem_alloc(sizeof(menuItem), "gui menu item")) == nullptr) {
- return nullptr;
- }
+ newItem = new menuItemVSlider();
// Initialize the struct
newItem->next = myMenu->itemList;
@@ -1534,7 +1455,7 @@ menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
myMenu->itemList = newItem;
- newItem->myMenu = (void *)myMenu;
+ newItem->myMenu = myMenu;
newItem->tag = tag;
newItem->x1 = x;
newItem->y1 = y;
@@ -1550,34 +1471,29 @@ menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
}
- if ((vsliderInfo = (menuItemVSlider *)mem_alloc(sizeof(menuItemVSlider), "menu item vslider")) == nullptr) {
- return nullptr;
- }
- vsliderInfo->itemFlags = VS_NORM;
+ newItem->itemFlags = VS_NORM;
- vsliderInfo->thumbW = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->w;
- vsliderInfo->thumbH = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->h;
+ newItem->thumbW = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->w;
+ newItem->thumbH = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->h;
- vsliderInfo->minThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + 1;
- vsliderInfo->maxThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + _GM(menuSprites)[SL_SCROLL_BAR]->h
+ newItem->minThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + 1;
+ newItem->maxThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + _GM(menuSprites)[SL_SCROLL_BAR]->h
- _GM(menuSprites)[SL_SLIDER_BTN_NORM]->h - 1;
// Calculate the initial thumbY
- vsliderInfo->percent = imath_max(imath_min(initPercent, 100), 0);
- vsliderInfo->thumbY = vsliderInfo->minThumbY +
- ((vsliderInfo->percent * (vsliderInfo->maxThumbY - vsliderInfo->minThumbY)) / 100);
-
- newItem->itemInfo = (void *)vsliderInfo;
+ newItem->percent = imath_max(imath_min(initPercent, 100), 0);
+ newItem->thumbY = newItem->minThumbY +
+ ((newItem->percent * (newItem->maxThumbY - newItem->minThumbY)) / 100);
- newItem->redraw = menu_DrawVSlider;
- newItem->destroy = item_Destroy;
- newItem->itemEventHandler = vslider_Handler;
+ newItem->redraw = (DrawFunction)menu_DrawVSlider;
+ newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->itemEventHandler = (ItemHandlerFunction)vslider_Handler;
// Draw the vslider in now
- (newItem->redraw)(newItem, (void *)myMenu, x, y, 0, 0);
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
// See if the screen is currently visible
- myScreen = vmng_screen_find((void *)myMenu, &status);
+ myScreen = vmng_screen_find(myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
@@ -1587,43 +1503,31 @@ menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
-void menu_DisableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu) {
- menuItemVSlider *mySlider;
-
+void menu_DisableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu) {
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return;
- }
- if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
- }
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
+ myItem = (menuItemVSlider *)menu_GetItem(tag, myMenu);
+ if (!myItem)
return;
- }
- mySlider = (menuItemVSlider *)myItem->itemInfo;
- mySlider->itemFlags = VS_GREY;
+ myItem->itemFlags = VS_GREY;
}
-void menu_EnableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu) {
- menuItemVSlider *mySlider;
-
+void menu_EnableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu) {
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return;
- }
- if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
- }
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
+ myItem = (menuItemVSlider *)menu_GetItem(tag, myMenu);
+ if (!myItem)
return;
- }
- mySlider = (menuItemVSlider *)myItem->itemInfo;
- mySlider->itemFlags = VS_NORM;
+ myItem->itemFlags = VS_NORM;
}
@@ -1635,9 +1539,7 @@ enum {
TF_GREY = 2
};
-void menu_DrawTextField(void *theItem, void *theMenu, int32 x, int32 y, int32, int32) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
+void menu_DrawTextField(menuItemTextField *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
menuItemTextField *myText = nullptr;
Buffer *myBuff = nullptr;
Buffer *backgroundBuff = nullptr;
@@ -1646,9 +1548,8 @@ void menu_DrawTextField(void *theItem, void *theMenu, int32 x, int32 y, int32, i
int32 cursorX;
// Verify params
- if ((!myItem) || (!myItem->itemInfo) || (!myMenu)) {
+ if (!myItem || !myMenu)
return;
- }
// If the item is marked transparent, get the background buffer
if (myItem->transparent) {
@@ -1661,9 +1562,7 @@ void menu_DrawTextField(void *theItem, void *theMenu, int32 x, int32 y, int32, i
}
}
- // Get the button info and select the sprite
- myText = (menuItemTextField *)myItem->itemInfo;
-
+ // Select the sprite
switch (myText->itemFlags) {
case TF_GREY:
mySprite = _GM(menuSprites)[SL_LINE_NORM];
@@ -1721,21 +1620,17 @@ void menu_DrawTextField(void *theItem, void *theMenu, int32 x, int32 y, int32, i
}
-bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- menuItem *myItem = (menuItem *)theItem;
- menuItemTextField *myText;
+bool textfield_Handler(menuItemTextField *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
bool redrawItem, execCallback, handled;
ScreenContext *myScreen;
int32 status, temp;
char tempStr[80], *tempPtr;
// Verify params
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
return false;
- }
- myText = (menuItemTextField *)myItem->itemInfo;
- if (myText->itemFlags == TF_GREY) {
+ if (myItem->itemFlags == TF_GREY) {
return false;
}
@@ -1749,7 +1644,7 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
case _ME_doubleclick:
_GM(deleteSaveDesc) = false;
if (menu_CursorInsideItem(myItem, x, y)) {
- *currItem = theItem;
+ *currItem = myItem;
}
break;
@@ -1764,10 +1659,10 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
}
*currItem = nullptr;
if (menu_CursorInsideItem(myItem, x, y)) {
- if (myText->itemFlags == TF_OVER) {
- temp = strlen(myText->prompt);
+ if (myItem->itemFlags == TF_OVER) {
+ temp = strlen(myItem->prompt);
if (temp > 0) {
- Common::strcpy_s(tempStr, myText->prompt);
+ Common::strcpy_s(tempStr, myItem->prompt);
tempPtr = &tempStr[temp];
gr_font_set(_GM(menuFont));
temp = gr_font_string_width(tempStr, -1);
@@ -1775,7 +1670,7 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
*--tempPtr = '\0';
temp = gr_font_string_width(tempStr, -1);
}
- myText->cursor = &myText->prompt[tempPtr - &tempStr[0]];
+ myItem->cursor = &myItem->prompt[tempPtr - &tempStr[0]];
redrawItem = true;
}
} else if (event == _ME_doubleclick_release) {
@@ -1789,7 +1684,7 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
case _ME_doubleclick_hold:
break;
}
- } else if ((eventType == EVENT_KEY) && (myText->itemFlags == TF_OVER)) {
+ } else if ((eventType == EVENT_KEY) && (myItem->itemFlags == TF_OVER)) {
switch (event) {
case KEY_RETURN:
_GM(deleteSaveDesc) = false;
@@ -1798,53 +1693,53 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
case KEY_HOME:
_GM(deleteSaveDesc) = false;
- myText->cursor = &myText->prompt[0];
+ myItem->cursor = &myItem->prompt[0];
redrawItem = true;
break;
case KEY_END:
_GM(deleteSaveDesc) = false;
- myText->cursor = myText->promptEnd;
+ myItem->cursor = myItem->promptEnd;
redrawItem = true;
break;
case KEY_LEFT:
_GM(deleteSaveDesc) = false;
- if (myText->cursor > &myText->prompt[0]) {
- myText->cursor--;
+ if (myItem->cursor > &myItem->prompt[0]) {
+ myItem->cursor--;
redrawItem = true;
}
break;
case KEY_RIGHT:
_GM(deleteSaveDesc) = false;
- if (myText->cursor < myText->promptEnd) {
- myText->cursor++;
+ if (myItem->cursor < myItem->promptEnd) {
+ myItem->cursor++;
redrawItem = true;
}
break;
case KEY_DELETE:
if (_GM(deleteSaveDesc)) {
- myText->prompt[0] = '\0';
- myText->promptEnd = &myText->prompt[0];
- myText->cursor = myText->promptEnd;
+ myItem->prompt[0] = '\0';
+ myItem->promptEnd = &myItem->prompt[0];
+ myItem->cursor = myItem->promptEnd;
redrawItem = true;
- } else if (myText->cursor < myText->promptEnd) {
- Common::strcpy_s(tempStr, (char *)(myText->cursor + 1));
- Common::strcpy_s(myText->cursor, 80, tempStr);
- myText->promptEnd--;
+ } else if (myItem->cursor < myItem->promptEnd) {
+ Common::strcpy_s(tempStr, (char *)(myItem->cursor + 1));
+ Common::strcpy_s(myItem->cursor, 80, tempStr);
+ myItem->promptEnd--;
redrawItem = true;
}
break;
case KEY_BACKSP:
_GM(deleteSaveDesc) = false;
- if (myText->cursor > &myText->prompt[0]) {
- Common::strcpy_s(tempStr, myText->cursor);
- myText->promptEnd--;
- myText->cursor--;
- Common::strcpy_s(myText->cursor, 80, tempStr);
+ if (myItem->cursor > &myItem->prompt[0]) {
+ Common::strcpy_s(tempStr, myItem->cursor);
+ myItem->promptEnd--;
+ myItem->cursor--;
+ Common::strcpy_s(myItem->cursor, 80, tempStr);
redrawItem = true;
}
break;
@@ -1852,17 +1747,17 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
default:
_GM(deleteSaveDesc) = false;
gr_font_set(_GM(menuFont));
- temp = gr_font_string_width(&myText->prompt[0], -1);
- if ((strlen(&myText->prompt[0]) < 79) && (temp < myText->pixWidth - 12) && (event >= 32) && (event <= 127)) {
- if (myText->cursor < myText->promptEnd) {
- Common::strcpy_s(tempStr, (char *)myText->cursor);
- Common::sprintf_s(myText->cursor, 80, "%c%s", (char)event, tempStr);
+ temp = gr_font_string_width(&myItem->prompt[0], -1);
+ if ((strlen(&myItem->prompt[0]) < 79) && (temp < myItem->pixWidth - 12) && (event >= 32) && (event <= 127)) {
+ if (myItem->cursor < myItem->promptEnd) {
+ Common::strcpy_s(tempStr, (char *)myItem->cursor);
+ Common::sprintf_s(myItem->cursor, 80, "%c%s", (char)event, tempStr);
} else {
- *myText->cursor = (char)event;
- *(myText->cursor + 1) = '\0';
+ *myItem->cursor = (char)event;
+ *(myItem->cursor + 1) = '\0';
}
- myText->cursor++;
- myText->promptEnd++;
+ myItem->cursor++;
+ myItem->promptEnd++;
redrawItem = true;
}
@@ -1878,8 +1773,8 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
// See if we need to redraw the button
if (redrawItem) {
- (myItem->redraw)((void *)myItem, (void *)myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
@@ -1888,8 +1783,8 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
// See if we need to call the callback function
if (execCallback && myItem->callback) {
- (myItem->callback)((void *)myItem, (void *)myItem->myMenu);
- myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
+ (myItem->callback)((void *)myItem, myItem->myMenu);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
if ((!myScreen) || (status != SCRN_ACTIVE)) {
*currItem = nullptr;
@@ -1900,22 +1795,19 @@ bool textfield_Handler(void *theItem, int32 eventType, int32 event, int32 x, int
}
-menuItem *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, int32 initFlags,
+menuItemTextField *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, int32 initFlags,
const char *prompt, int32 specialTag, CALLBACK callback, bool transparent) {
- menuItem *newItem;
+ menuItemTextField *newItem;
menuItemTextField *textInfo;
ScreenContext *myScreen;
int32 status;
// Verify params
- if (!myMenu) {
+ if (!myMenu)
return nullptr;
- }
// Allocate a new one
- if ((newItem = (menuItem *)mem_alloc(sizeof(menuItem), "gui menu item")) == nullptr) {
- return nullptr;
- }
+ newItem = new menuItemTextField();
// Initialize the struct
newItem->next = myMenu->itemList;
@@ -1925,7 +1817,7 @@ menuItem *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32
}
myMenu->itemList = newItem;
- newItem->myMenu = (void *)myMenu;
+ newItem->myMenu = myMenu;
newItem->tag = tag;
newItem->x1 = x;
newItem->y1 = y;
@@ -1957,17 +1849,15 @@ menuItem *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32
}
textInfo->cursor = textInfo->promptEnd;
- newItem->itemInfo = (void *)textInfo;
-
- newItem->redraw = menu_DrawTextField;
- newItem->destroy = item_Destroy;
- newItem->itemEventHandler = textfield_Handler;
+ newItem->redraw = (DrawFunction)menu_DrawTextField;
+ newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->itemEventHandler = (ItemHandlerFunction)textfield_Handler;
// Draw the vslider in now
- (newItem->redraw)(newItem, (void *)myMenu, x, y, 0, 0);
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
// See if the screen is currently visible
- myScreen = vmng_screen_find((void *)myMenu, &status);
+ myScreen = vmng_screen_find(myMenu, &status);
if (myScreen && (status == SCRN_ACTIVE)) {
RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
@@ -2175,15 +2065,10 @@ void cb_Options_Game_Done(void *, void *) {
CreateGameMenuMain(nullptr);
}
-void cb_Options_Digi(void *theItem, void *theMenu) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItemHSlider *mySlider;
-
- mySlider = (menuItemHSlider *)myItem->itemInfo;
+void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
// Set the digi volume
- digi_set_overall_volume(mySlider->percent);
- term_message("digi volume: %d", mySlider->percent);
+ digi_set_overall_volume(myItem->percent);
+ term_message("digi volume: %d", myItem->percent);
// This scroller control has been moved, so make sure that the DONE button is not greyed out
menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
@@ -2191,15 +2076,9 @@ void cb_Options_Digi(void *theItem, void *theMenu) {
}
-void cb_Options_Digestability(void *theItem, void *theMenu) {
- menuItem *myItem = (menuItem *)theItem;
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItemHSlider *mySlider;
-
- mySlider = (menuItemHSlider *)myItem->itemInfo;
- // Set the midi volume
- term_message("digestability: %d", mySlider->percent);
- _G(flags)[digestability] = mySlider->percent;
+void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
+ term_message("digestability: %d", myItem->percent);
+ _G(flags)[digestability] = myItem->percent;
// This scroller control has been moved, so make sure that the DONE button is not greyed out
menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
@@ -2207,10 +2086,8 @@ void cb_Options_Digestability(void *theItem, void *theMenu) {
}
void DestroyOptionsMenu(void) {
-
- if (!_GM(opMenu)) {
+ if (!_GM(opMenu))
return;
- }
// Remove the screen from the gui
vmng_screen_dispose(_GM(opMenu));
@@ -2244,9 +2121,11 @@ void CreateOptionsMenu(RGB8 *myPalette) {
menu_ButtonAdd(_GM(opMenu), OM_TAG_CANCEL, OM_CANCEL_X, OM_CANCEL_Y, OM_CANCEL_W, OM_CANCEL_H, cb_Options_Game_Cancel, BTN_TYPE_OM_CANCEL);
menu_ButtonAdd(_GM(opMenu), OM_TAG_DONE, OM_DONE_X, OM_DONE_Y, OM_DONE_W, OM_DONE_H, cb_Options_Game_Done, BTN_TYPE_OM_DONE, true);
- menu_HSliderAdd(_GM(opMenu), OM_TAG_DIGI, OM_DIGI_X, OM_DIGI_Y, OM_DIGI_W, OM_DIGI_H, digi_get_overall_volume(), cb_Options_Digi, true);
+ menu_HSliderAdd(_GM(opMenu), OM_TAG_DIGI, OM_DIGI_X, OM_DIGI_Y, OM_DIGI_W, OM_DIGI_H, digi_get_overall_volume(),
+ (CALLBACK)cb_Options_Digi, true);
menu_HSliderAdd(_GM(opMenu), OM_TAG_DIGESTABILITY, OM_DIGESTABILITY_X, OM_DIGESTABILITY_Y,
- OM_DIGESTABILITY_W, OM_DIGESTABILITY_H, _G(flags)[digestability], cb_Options_Digestability, true);
+ OM_DIGESTABILITY_W, OM_DIGESTABILITY_H, _G(flags)[digestability],
+ (CALLBACK)cb_Options_Digestability, true);
// Remember the values of the items in case the user cancels
_GM(remember_digi_volume) = digi_get_overall_volume();
@@ -2263,7 +2142,7 @@ void CreateOptionsMenu(RGB8 *myPalette) {
//-------------------------------- ERR MENU --------------------------------------//
//------------------------------------------------------------------------------------//
-void DestroyErrMenu(void);
+void DestroyErrMenu();
void cb_Err_Done(void *, void *) {
// Destroy the game menu
@@ -2345,8 +2224,8 @@ void CreateErrMenu(RGB8 *myPalette) {
//-------------------------------- SAVE / LOAD MENU -----------------------------------//
void DestroySaveLoadMenu(bool saveMenu);
-void cb_SaveLoad_Slot(void *theItem, void *theMenu);
-bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
+void cb_SaveLoad_Slot(menuItemButton *theItem, guiMenu *myMenu);
+bool load_Handler(menuItemButton *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
bool LoadThumbNail(int32 slotNum) {
@@ -2424,7 +2303,6 @@ void UpdateThumbNails(int32 firstSlot, guiMenu *myMenu) {
void SetFirstSlot(int32 firstSlot, guiMenu *myMenu) {
- menuItem *tempItem;
menuItemButton *myButton;
int32 i;
@@ -2437,63 +2315,57 @@ void SetFirstSlot(int32 firstSlot, guiMenu *myMenu) {
// Change the prompt and special tag of each of the slot buttons
for (i = 0; i < MAX_SLOTS_SHOWN; i++) {
- tempItem = menu_GetItem(i + 1001, myMenu);
- myButton = (menuItemButton *)tempItem->itemInfo;
+ myButton = (menuItemButton *)menu_GetItem(i + 1001, myMenu);
+
myButton->prompt = _GM(slotTitles)[firstSlot + i];
if (_GM(currMenuIsSave) || _GM(slotInUse)[firstSlot + i]) {
myButton->itemFlags = BTN_STATE_NORM;
} else {
myButton->itemFlags = BTN_STATE_GREY;
}
+
myButton->specialTag = firstSlot + i + 1;
- menu_ItemRefresh(tempItem, i + 1001, myMenu);
+ menu_ItemRefresh(myButton, i + 1001, myMenu);
}
}
-void cb_SaveLoad_VSlider(void *theItem, void *theMenu) {
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItem *myItem = (menuItem *)theItem;
- menuItemVSlider *mySlider;
+void cb_SaveLoad_VSlider(menuItemVSlider *myItem, guiMenu *myMenu) {
bool redraw;
- if ((!myMenu) || (!myItem) || (!myItem->itemInfo)) {
+ if (!myMenu || !myItem)
return;
- }
- // Get my slider
- mySlider = (menuItemVSlider *)myItem->itemInfo;
+ if ((myItem->itemFlags & VS_COMPONENT) != VS_THUMB) {
- if ((mySlider->itemFlags & VS_COMPONENT) != VS_THUMB) {
-
- redraw = false;
- switch (mySlider->itemFlags & VS_COMPONENT) {
+ redraw = (DrawFunction)false;
+ switch (myItem->itemFlags & VS_COMPONENT) {
case VS_UP:
if (_GM(firstSlotIndex) > 0) {
_GM(firstSlotIndex)--;
- redraw = true;
+ redraw = (DrawFunction)true;
}
break;
case VS_PAGE_UP:
if (_GM(firstSlotIndex) > 0) {
_GM(firstSlotIndex) = imath_max(_GM(firstSlotIndex) - 10, 0);
- redraw = true;
+ redraw = (DrawFunction)true;
}
break;
case VS_PAGE_DOWN:
if (_GM(firstSlotIndex) < 89) {
_GM(firstSlotIndex) = imath_min(_GM(firstSlotIndex) + 10, 89);
- redraw = true;
+ redraw = (DrawFunction)true;
}
break;
case VS_DOWN:
if (_GM(firstSlotIndex) < 89) {
_GM(firstSlotIndex)++;
- redraw = true;
+ redraw = (DrawFunction)true;
}
break;
}
@@ -2503,11 +2375,11 @@ void cb_SaveLoad_VSlider(void *theItem, void *theMenu) {
SetFirstSlot(_GM(firstSlotIndex), myMenu);
// Calculate the new percent
- mySlider->percent = (_GM(firstSlotIndex) * 100) / 89;
+ myItem->percent = (_GM(firstSlotIndex) * 100) / 89;
// Calculate the new thumbY
- mySlider->thumbY = mySlider->minThumbY +
- ((mySlider->percent * (mySlider->maxThumbY - mySlider->minThumbY)) / 100);
+ myItem->thumbY = myItem->minThumbY +
+ ((myItem->percent * (myItem->maxThumbY - myItem->minThumbY)) / 100);
// Redraw the slider
menu_ItemRefresh(myItem, -1, myMenu);
@@ -2516,15 +2388,13 @@ void cb_SaveLoad_VSlider(void *theItem, void *theMenu) {
// Else the callback came from the thumb - set the _GM(firstSlotIndex) based on the slider percent
else {
- _GM(firstSlotIndex) = (mySlider->percent * 89) / 100;
+ _GM(firstSlotIndex) = (myItem->percent * 89) / 100;
SetFirstSlot(_GM(firstSlotIndex), myMenu);
}
}
-void cb_SaveLoad_Save(void *, void *theMenu) {
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItem *myTextItem;
+void cb_SaveLoad_Save(void *, guiMenu *myMenu) {
menuItemTextField *myText;
bool saveGameFailed;
@@ -2534,11 +2404,10 @@ void cb_SaveLoad_Save(void *, void *theMenu) {
}
// First make the textfield NORM
- myTextItem = menu_GetItem(2000, myMenu);
- if ((!myTextItem) || (!myTextItem->itemInfo)) {
+ myText = (menuItemTextField *)menu_GetItem(2000, myMenu);
+ if (myText)
return;
- }
- myText = (menuItemTextField *)myTextItem->itemInfo;
+
myText->itemFlags = TF_NORM;
// Set the vars
@@ -2569,7 +2438,7 @@ void cb_SaveLoad_Save(void *, void *theMenu) {
}
-void cb_SaveLoad_Load(void *, void *theMenu) {
+void cb_SaveLoad_Load(menuItemButton *, guiMenu *) {
KernelTriggerType oldMode;
// If (slotSelected < 0) this callback is being executed by pressing return prematurely
@@ -2600,8 +2469,7 @@ void cb_SaveLoad_Load(void *, void *theMenu) {
}
-void cb_SaveLoad_Cancel(void *, void *theMenu) {
- guiMenu *myMenu = (guiMenu *)theMenu;
+void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
menuItem *myItem;
int32 i, x, y, w, h;
@@ -2628,10 +2496,12 @@ void cb_SaveLoad_Cancel(void *, void *theMenu) {
// Add the button back in
if (_GM(currMenuIsSave)) {
menu_ButtonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
- cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1], button_Handler);
+ (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1],
+ (ItemHandlerFunction)button_Handler);
} else {
menu_ButtonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
- cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1], load_Handler);
+ (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1],
+ (ItemHandlerFunction)load_Handler);
// Remove the thumbnail
if (_GM(saveLoadThumbNail)) {
@@ -2676,21 +2546,16 @@ void cb_SaveLoad_Cancel(void *, void *theMenu) {
}
-void cb_SaveLoad_Slot(void *theItem, void *theMenu) {
- guiMenu *myMenu = (guiMenu *)theMenu;
- menuItem *myItem = (menuItem *)theItem;
- menuItemButton *myButton;
+void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
int32 i, x, y, w, h;
char prompt[80];
int32 specialTag;
// Verify params
- if ((!myMenu) || (!myItem) || (!myItem->itemInfo)) {
+ if (!myMenu || !myButton)
return;
- }
// Get the button
- myButton = (menuItemButton *)myItem->itemInfo;
Common::strcpy_s(prompt, 80, myButton->prompt);
specialTag = myButton->specialTag;
@@ -2700,31 +2565,31 @@ void cb_SaveLoad_Slot(void *theItem, void *theMenu) {
// Disable all other buttons
for (i = 1001; i <= 1010; i++) {
- if (i != myItem->tag) {
+ if (i != myButton->tag) {
menu_DisableButton(nullptr, i, myMenu);
menu_ItemRefresh(nullptr, i, myMenu);
}
}
// Get the slot coords, and delete it
- x = myItem->x1;
- y = myItem->y1;
- w = myItem->x2 - myItem->x1 + 1;
- h = myItem->y2 - myItem->y1 + 1;
- menu_ItemDelete(myItem, -1, myMenu);
+ x = myButton->x1;
+ y = myButton->y1;
+ w = myButton->x2 - myButton->x1 + 1;
+ h = myButton->y2 - myButton->y1 + 1;
+ menu_ItemDelete(myButton, -1, myMenu);
if (_GM(currMenuIsSave)) {
// Replace the current button with a textfield
if (!strcmp(prompt, "<empty>")) {
menu_TextFieldAdd(myMenu, 2000, x, y, w, h, TF_OVER,
- nullptr, specialTag, cb_SaveLoad_Save, true);
+ nullptr, specialTag, (CALLBACK)cb_SaveLoad_Save, true);
} else {
menu_TextFieldAdd(myMenu, 2000, x, y, w, h, TF_OVER,
- prompt, specialTag, cb_SaveLoad_Save, true);
+ prompt, specialTag, (CALLBACK)cb_SaveLoad_Save, true);
}
} else {
menu_TextFieldAdd(myMenu, 2000, x, y, w, h, TF_NORM,
- prompt, specialTag, cb_SaveLoad_Load, true);
+ prompt, specialTag, (CALLBACK)cb_SaveLoad_Load, true);
}
// Disable the slider
@@ -2759,13 +2624,11 @@ void InitializeSlotTables(void) {
}
}
-bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- menuItem *myItem = (menuItem *)theItem;
- menuItemButton *myButton;
+bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
bool handled;
// Handle the event just like any other button
- handled = button_Handler(theItem, eventType, event, x, y, currItem);
+ handled = button_Handler(myItem, eventType, event, x, y, currItem);
// If we've selected a slot, we want the thumbNail to remain on the menu permanently
if (_GM(slotSelected) >= 0) {
@@ -2777,16 +2640,14 @@ bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y,
(event == _ME_doubleclick_drag) || (event == _ME_doubleclick_release))) {
// Get the button
- if ((!myItem) || (!myItem->itemInfo)) {
+ if (!myItem)
return handled;
- }
- myButton = (menuItemButton *)myItem->itemInfo;
// This determines that we are over the button
- if ((myButton->itemFlags == BTN_STATE_OVER) || (myButton->itemFlags == BTN_STATE_PRESS)) {
+ if ((myItem->itemFlags == BTN_STATE_OVER) || (myItem->itemFlags == BTN_STATE_PRESS)) {
// See if the current _GM(saveLoadThumbNail) is pointing to the correct sprite
- if (_GM(saveLoadThumbNail) != _GM(thumbNails)[myButton->specialTag - 1]) {
- _GM(saveLoadThumbNail) = _GM(thumbNails)[myButton->specialTag - 1];
+ if (_GM(saveLoadThumbNail) != _GM(thumbNails)[myItem->specialTag - 1]) {
+ _GM(saveLoadThumbNail) = _GM(thumbNails)[myItem->specialTag - 1];
menu_ItemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
}
}
@@ -2810,6 +2671,7 @@ bool load_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y,
}
}
}
+
return handled;
}
@@ -2880,34 +2742,34 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
if (_GM(currMenuIsSave)) {
menu_MsgAdd(_GM(slMenu), SL_TAG_SAVE_LABEL, SL_SAVE_LABEL_X, SL_SAVE_LABEL_Y, SL_SAVE_LABEL_W, SL_SAVE_LABEL_H);
menu_ButtonAdd(_GM(slMenu), SL_TAG_SAVE, SL_SAVE_X, SL_SAVE_Y, SL_SAVE_W, SL_SAVE_H,
- cb_SaveLoad_Save, BTN_TYPE_SL_SAVE, true);
+ (CALLBACK)cb_SaveLoad_Save, BTN_TYPE_SL_SAVE, true);
} else {
menu_MsgAdd(_GM(slMenu), SL_TAG_LOAD_LABEL, SL_LOAD_LABEL_X, SL_LOAD_LABEL_Y, SL_LOAD_LABEL_W, SL_LOAD_LABEL_H);
menu_ButtonAdd(_GM(slMenu), SL_TAG_LOAD, SL_LOAD_X, SL_LOAD_Y, SL_LOAD_W, SL_LOAD_H,
- cb_SaveLoad_Load, BTN_TYPE_SL_LOAD, true);
+ (CALLBACK)cb_SaveLoad_Load, BTN_TYPE_SL_LOAD, true);
}
menu_ButtonAdd(_GM(slMenu), SL_TAG_CANCEL, SL_CANCEL_X, SL_CANCEL_Y, SL_CANCEL_W, SL_CANCEL_H,
- cb_SaveLoad_Cancel, BTN_TYPE_SL_CANCEL);
+ (CALLBACK)cb_SaveLoad_Cancel, BTN_TYPE_SL_CANCEL);
menu_VSliderAdd(_GM(slMenu), SL_TAG_VSLIDER, SL_SLIDER_X, SL_SLIDER_Y, SL_SLIDER_W, SL_SLIDER_H,
- 0, cb_SaveLoad_VSlider);
+ 0, (CALLBACK)cb_SaveLoad_VSlider);
InitializeSlotTables();
if (_GM(currMenuIsSave)) {
buttonGreyed = false;
- i_handler = button_Handler;
+ i_handler = (ItemHandlerFunction)button_Handler;
} else {
buttonGreyed = true;
- i_handler = load_Handler;
+ i_handler = (ItemHandlerFunction)load_Handler;
}
for (int32 i = 0; i < MAX_SLOTS_SHOWN; i++) {
menu_ButtonAdd(_GM(slMenu), 1001 + i,
SL_SCROLL_FIELD_X, SL_SCROLL_FIELD_Y + i * SL_SCROLL_LINE_H,
SL_SCROLL_LINE_W, SL_SCROLL_LINE_H,
- cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT,
+ (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT,
buttonGreyed && (!_GM(slotInUse)[i]), true, _GM(slotTitles)[i], i_handler);
}
@@ -2928,11 +2790,11 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
if (_GM(currMenuIsSave)) {
//<return> - if a slot has been selected, saves the game
//<esc> - cancels and returns to the game menu
- menu_Configure(_GM(slMenu), cb_SaveLoad_Save, cb_SaveLoad_Cancel);
+ menu_Configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Save, (CALLBACK)cb_SaveLoad_Cancel);
} else {
//<return> - if a slot has been selected, loads the selected game
//<esc> - cancels and returns to the game menu
- menu_Configure(_GM(slMenu), cb_SaveLoad_Load, cb_SaveLoad_Cancel);
+ menu_Configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Load, (CALLBACK)cb_SaveLoad_Cancel);
}
vmng_screen_show((void *)_GM(slMenu));
diff --git a/engines/m4/burger/gui/game_menu.h b/engines/m4/burger/gui/game_menu.h
index a4fb0e96bc7..ad365960f74 100644
--- a/engines/m4/burger/gui/game_menu.h
+++ b/engines/m4/burger/gui/game_menu.h
@@ -34,7 +34,11 @@ namespace Burger {
namespace GUI {
using M4::GUI::guiMenu;
-using M4::GUI::menuItem;
+using M4::GUI::menuItemButton;
+using M4::GUI::menuItemMsg;
+using M4::GUI::menuItemHSlider;
+using M4::GUI::menuItemVSlider;
+using M4::GUI::menuItemTextField;
using M4::GUI::Sprite;
using M4::GUI::CALLBACK;
using M4::GUI::ItemHandlerFunction;
@@ -42,30 +46,30 @@ using M4::GUI::ItemHandlerFunction;
// SPECIFIC ITEM FUNCTIONS
// Messages
-menuItem *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, bool transparent = false);
-void menu_DisableMsg(menuItem *myItem, int32 tag, guiMenu *myMenu);
-void menu_EnableMsg(menuItem *myItem, int32 tag, guiMenu *myMenu);
+extern menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, bool transparent = false);
+extern void menu_DisableMsg(menuItemMsg *myItem, int32 tag, guiMenu *myMenu);
+extern void menu_EnableMsg(menuItemMsg *myItem, int32 tag, guiMenu *myMenu);
// Buttons
-bool button_Handler(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
-menuItem *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback = nullptr,
+bool button_Handler(menuItemButton *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
+menuItemButton *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback = nullptr,
int32 buttonType = 0, bool ghosted = false, bool transparent = false,
- const char *prompt = nullptr, ItemHandlerFunction i_handler = button_Handler);
-void menu_DisableButton(menuItem *myItem, int32 tag, guiMenu *myMenu);
-void menu_EnableButton(menuItem *myItem, int32 tag, guiMenu *myMenu);
+ const char *prompt = nullptr, ItemHandlerFunction i_handler = (ItemHandlerFunction)button_Handler);
+void menu_DisableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
+void menu_EnableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
// Horizontal sliders
-menuItem *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
+menuItemHSlider *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
int32 initPercent = 0, CALLBACK callback = nullptr, bool transparent = false);
// Vertical sliders
-menuItem *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
+menuItemVSlider *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
int32 initPercent = 0, CALLBACK callback = nullptr, bool transparent = false);
-void menu_DisableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu);
-void menu_EnableVSlider(menuItem *myItem, int32 tag, guiMenu *myMenu);
+void menu_DisableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu);
+void menu_EnableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu);
// Textfields
-menuItem *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, int32 initFlags,
+menuItemTextField *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, int32 initFlags,
const char *prompt = nullptr, int32 specialtag = 0, CALLBACK callback = nullptr, bool transparent = false);
//GAME MENU FUNCTIONS
diff --git a/engines/m4/gui/gui_menu.cpp b/engines/m4/gui/gui_menu.cpp
index 849b4e6a2ad..eef18c0f15a 100644
--- a/engines/m4/gui/gui_menu.cpp
+++ b/engines/m4/gui/gui_menu.cpp
@@ -286,16 +286,15 @@ void menu_Show(void *s, void *r, void *b, int32 destX, int32 destY) {
guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags) {
guiMenu *newMenu;
Buffer *tempBuff, drawSpriteBuff;
- DrawRequest spriteDrawReq;
+ DrawRequest spriteDrawReq;
// Verify params
if (!backgroundSprite) {
return nullptr;
}
- if ((newMenu = (guiMenu *)mem_alloc(sizeof(guiMenu), "gui menu")) == nullptr) {
- return nullptr;
- }
+ newMenu = new guiMenu();
+
newMenu->menuBuffer = new GrBuff(backgroundSprite->w, backgroundSprite->h);
newMenu->itemList = nullptr;
newMenu->cb_return = nullptr;
@@ -364,7 +363,7 @@ void menu_Destroy(guiMenu *myMenu) {
myItem = myMenu->itemList;
while (myItem) {
myMenu->itemList = myItem->next;
- (myItem->destroy)((void *)myItem);
+ (myItem->destroy)(myItem);
myItem = myMenu->itemList;
}
@@ -372,7 +371,7 @@ void menu_Destroy(guiMenu *myMenu) {
delete myMenu->menuBuffer;
// Destroy the menu
- mem_free((void *)myMenu);
+ delete myMenu;
}
void menu_Configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc) {
@@ -574,7 +573,7 @@ void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu) {
// Destroy the item;
if (myItem->destroy) {
- myItem->destroy((void *)myItem);
+ myItem->destroy(myItem);
}
}
@@ -595,7 +594,7 @@ void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
}
// Draw myItem
- (myItem->redraw)(myItem, (void *)myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
// Update the video
myScreen = vmng_screen_find((void *)myItem->myMenu, &status);
diff --git a/engines/m4/gui/gui_menu.h b/engines/m4/gui/gui_menu.h
index d17c5b11367..57413b65527 100644
--- a/engines/m4/gui/gui_menu.h
+++ b/engines/m4/gui/gui_menu.h
@@ -35,9 +35,12 @@ namespace GUI {
#define LockMouseSprite mouse_lock_sprite
#define UnlockMouseSprite mouse_unlock_sprite
-typedef bool (*ItemHandlerFunction)(void *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
-typedef void (*DrawFunction)(void *source, void *dest, int32 x1, int32 y1, int32 x2, int32 y2);
-typedef void (*DestroyFunction)(void *theItem);
+struct menuItem;
+struct guiMenu;
+
+typedef bool (*ItemHandlerFunction)(menuItem *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
+typedef void (*DrawFunction)(void *source, guiMenu *dest, int32 x1, int32 y1, int32 x2, int32 y2);
+typedef void (*DestroyFunction)(menuItem *theItem);
typedef M4CALLBACK CALLBACK;
typedef M4sprite Sprite;
@@ -53,12 +56,13 @@ enum game_menu_sprites {
GM_TOTAL_SPRITES
};
+struct guiMenu;
struct menuItem {
menuItem *next;
menuItem *prev;
- void *myMenu;
+ guiMenu *myMenu;
int32 tag;
int32 x1, y1, x2, y2;
@@ -66,8 +70,6 @@ struct menuItem {
bool transparent;
GrBuff *background;
- void *itemInfo;
-
CALLBACK callback;
DrawFunction redraw;
DestroyFunction destroy;
@@ -75,11 +77,11 @@ struct menuItem {
};
-struct menuItemMsg {
+struct menuItemMsg : public menuItem {
int32 itemFlags;
};
-struct menuItemButton {
+struct menuItemButton : public menuItem {
int32 itemFlags;
int32 buttonType;
const char *prompt;
@@ -87,7 +89,7 @@ struct menuItemButton {
int32 specialTag;
};
-struct menuItemHSlider {
+struct menuItemHSlider : public menuItem {
int32 itemFlags;
int32 thumbW, thumbH;
@@ -96,7 +98,7 @@ struct menuItemHSlider {
int32 percent;
};
-struct menuItemVSlider {
+struct menuItemVSlider : public menuItem {
int32 itemFlags;
int32 thumbW, thumbH;
@@ -105,7 +107,7 @@ struct menuItemVSlider {
int32 percent;
};
-struct menuItemTextField {
+struct menuItemTextField : public menuItem {
int32 itemFlags;
int32 specialTag;
Commit: de8faee2fc6e5f01358d69bf6d8ce9d37794f2dd
https://github.com/scummvm/scummvm/commit/de8faee2fc6e5f01358d69bf6d8ce9d37794f2dd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-12T20:41:30-08:00
Commit Message:
M4: RIDDLE: Move dialog gui functions into guiMenu class
Changed paths:
engines/m4/burger/gui/game_menu.cpp
engines/m4/gui/gui_menu.cpp
engines/m4/gui/gui_menu.h
engines/m4/riddle/gui/game_menu.cpp
diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index e720435e7ea..c03bec951d5 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -396,7 +396,7 @@ menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
newItem->background = nullptr;
} else {
newItem->transparent = true;
- newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
}
newItem->redraw = (DrawFunction)menu_DrawMsg;
@@ -753,7 +753,7 @@ bool button_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32
if ((!myScreen) || (status != SCRN_ACTIVE)) {
*currItem = nullptr;
} else {
- tempItem = menu_GetItem(currTag, currMenu);
+ tempItem = guiMenu::getItem(currTag, currMenu);
if (!tempItem) {
*currItem = nullptr;
}
@@ -799,7 +799,7 @@ menuItemButton *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int
newItem->background = nullptr;
} else {
newItem->transparent = true;
- newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
}
if (greyed) {
@@ -837,7 +837,7 @@ void menu_DisableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
return;
if (!myItem)
- myItem = (menuItemButton *)menu_GetItem(tag, myMenu);
+ myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
if (!myItem)
return;
@@ -851,7 +851,7 @@ void menu_EnableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
return;
if (!myItem)
- myItem = (menuItemButton *)menu_GetItem(tag, myMenu);
+ myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
if (!myItem)
return;
@@ -1098,7 +1098,7 @@ menuItemHSlider *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, i
newItem->background = nullptr;
} else {
newItem->transparent = true;
- newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
}
// Intialize the new slider
@@ -1468,7 +1468,7 @@ menuItemVSlider *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, i
newItem->background = nullptr;
} else {
newItem->transparent = true;
- newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
}
newItem->itemFlags = VS_NORM;
@@ -1509,7 +1509,7 @@ void menu_DisableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu) {
return;
if (!myItem)
- myItem = (menuItemVSlider *)menu_GetItem(tag, myMenu);
+ myItem = (menuItemVSlider *)guiMenu::getItem(tag, myMenu);
if (!myItem)
return;
@@ -1523,7 +1523,7 @@ void menu_EnableVSlider(menuItemVSlider *myItem, int32 tag, guiMenu *myMenu) {
return;
if (!myItem)
- myItem = (menuItemVSlider *)menu_GetItem(tag, myMenu);
+ myItem = (menuItemVSlider *)guiMenu::getItem(tag, myMenu);
if (!myItem)
return;
@@ -1830,7 +1830,7 @@ menuItemTextField *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32
newItem->background = nullptr;
} else {
newItem->transparent = true;
- newItem->background = menu_CopyBackground(myMenu, x, y, w, h);
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
}
if ((textInfo = (menuItemTextField *)mem_alloc(sizeof(menuItemTextField), "menu item textfield")) == nullptr) {
@@ -1912,7 +1912,7 @@ void cb_Game_Quit(void *, void *) {
DestroyGameMenu();
// Shutdown the menu system
- menu_Shutdown(false);
+ guiMenu::shutdown(false);
// Set the global that will cause the entire game to exit to dos
_G(kernel).going = false;
@@ -1923,13 +1923,13 @@ void cb_Game_Resume(void *, void *) {
DestroyGameMenu();
// Shutdown the menu system
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
void cb_Game_Save(void *, void *) {
// Destroy the game menu
DestroyGameMenu();
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
buttonClosesDialog = true;
// Create the save game menu
@@ -1939,7 +1939,7 @@ void cb_Game_Save(void *, void *) {
void cb_Game_Load(void *, void *) {
// Destroy the game menu
DestroyGameMenu();
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
buttonClosesDialog = true;
// Create the save game menu
@@ -1960,9 +1960,9 @@ void cb_Game_Main(void *, void *) {
_GM(interfaceWasVisible) = false;
// Shutdown the menu system
- menu_Shutdown(false);
+ guiMenu::shutdown(false);
} else {
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
// Go to the main menu
@@ -1987,15 +1987,15 @@ void DestroyGameMenu(void) {
vmng_screen_dispose(_GM(gameMenu));
// Destroy the menu resources
- menu_Destroy(_GM(gameMenu));
+ guiMenu::destroy(_GM(gameMenu));
// Unload the menu sprites
- menu_UnloadSprites();
+ guiMenu::unloadSprites();
}
void CreateGameMenuMain(RGB8 *myPalette) {
if (!_G(menuSystemInitialized)) {
- menu_Initialize(myPalette);
+ guiMenu::initialize(myPalette);
}
// Keep the memory tidy
@@ -2003,11 +2003,11 @@ void CreateGameMenuMain(RGB8 *myPalette) {
CompactMem();
// Load in the game menu sprites
- if (!menu_LoadSprites("gamemenu", GM_TOTAL_SPRITES)) {
+ if (!guiMenu::loadSprites("gamemenu", GM_TOTAL_SPRITES)) {
return;
}
- _GM(gameMenu) = menu_Create(_GM(menuSprites)[GM_DIALOG_BOX], GAME_MENU_X, GAME_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
+ _GM(gameMenu) = guiMenu::create(_GM(menuSprites)[GM_DIALOG_BOX], GAME_MENU_X, GAME_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
if (!_GM(gameMenu)) {
return;
}
@@ -2031,7 +2031,7 @@ void CreateGameMenuMain(RGB8 *myPalette) {
}
// Configure the game so pressing <esc> will cause the menu to disappear and the game to resume
- menu_Configure(_GM(gameMenu), cb_Game_Resume, cb_Game_Resume);
+ guiMenu::configure(_GM(gameMenu), cb_Game_Resume, cb_Game_Resume);
vmng_screen_show((void *)_GM(gameMenu));
LockMouseSprite(0);
@@ -2072,7 +2072,7 @@ void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
// This scroller control has been moved, so make sure that the DONE button is not greyed out
menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
- menu_ItemRefresh(nullptr, OM_TAG_DONE, myMenu);
+ guiMenu::itemRefresh(nullptr, OM_TAG_DONE, myMenu);
}
@@ -2082,7 +2082,7 @@ void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
// This scroller control has been moved, so make sure that the DONE button is not greyed out
menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
- menu_ItemRefresh(nullptr, OM_TAG_DONE, myMenu);
+ guiMenu::itemRefresh(nullptr, OM_TAG_DONE, myMenu);
}
void DestroyOptionsMenu(void) {
@@ -2093,16 +2093,16 @@ void DestroyOptionsMenu(void) {
vmng_screen_dispose(_GM(opMenu));
// Destroy the menu resources
- menu_Destroy(_GM(opMenu));
+ guiMenu::destroy(_GM(opMenu));
// Unload the menu sprites
- menu_UnloadSprites();
+ guiMenu::unloadSprites();
}
void CreateOptionsMenu(RGB8 *myPalette) {
if (!_G(menuSystemInitialized)) {
- menu_Initialize(myPalette);
+ guiMenu::initialize(myPalette);
}
// Keep the memory tidy
@@ -2110,11 +2110,11 @@ void CreateOptionsMenu(RGB8 *myPalette) {
CompactMem();
// Load in the game menu sprites
- if (!menu_LoadSprites("opmenu", OM_TOTAL_SPRITES)) {
+ if (!guiMenu::loadSprites("opmenu", OM_TOTAL_SPRITES)) {
return;
}
- _GM(opMenu) = menu_Create(_GM(menuSprites)[OM_DIALOG_BOX], OPTIONS_MENU_X, OPTIONS_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
+ _GM(opMenu) = guiMenu::create(_GM(menuSprites)[OM_DIALOG_BOX], OPTIONS_MENU_X, OPTIONS_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
if (!_GM(opMenu)) {
return;
}
@@ -2132,7 +2132,7 @@ void CreateOptionsMenu(RGB8 *myPalette) {
_GM(remember_digestability) = _G(flags)[digestability];
// Configure the game so pressing <esc> will cause the menu to disappear and the gamemenu to reappear
- menu_Configure(_GM(opMenu), cb_Options_Game_Done, cb_Options_Game_Cancel);
+ guiMenu::configure(_GM(opMenu), cb_Options_Game_Done, cb_Options_Game_Cancel);
vmng_screen_show((void *)_GM(opMenu));
LockMouseSprite(0);
@@ -2149,7 +2149,7 @@ void cb_Err_Done(void *, void *) {
DestroyErrMenu();
// Shutdown the menu system
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
@@ -2162,10 +2162,10 @@ void DestroyErrMenu(void) {
vmng_screen_dispose(_GM(errMenu));
// Destroy the menu resources
- menu_Destroy(_GM(errMenu));
+ guiMenu::destroy(_GM(errMenu));
// Unload the menu sprites
- menu_UnloadSprites();
+ guiMenu::unloadSprites();
}
@@ -2173,7 +2173,7 @@ void CreateErrMenu(RGB8 *myPalette) {
Buffer *myBuff;
if (!_G(menuSystemInitialized)) {
- menu_Initialize(myPalette);
+ guiMenu::initialize(myPalette);
}
// Keep the memory tidy
@@ -2181,11 +2181,11 @@ void CreateErrMenu(RGB8 *myPalette) {
CompactMem();
// Load in the game menu sprites
- if (!menu_LoadSprites("errmenu", 5)) {
+ if (!guiMenu::loadSprites("errmenu", 5)) {
return;
}
- _GM(errMenu) = menu_Create(_GM(menuSprites)[EM_DIALOG_BOX], ERROR_MENU_X, ERROR_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
+ _GM(errMenu) = guiMenu::create(_GM(menuSprites)[EM_DIALOG_BOX], ERROR_MENU_X, ERROR_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
if (!_GM(errMenu)) {
return;
}
@@ -2214,7 +2214,7 @@ void CreateErrMenu(RGB8 *myPalette) {
menu_ButtonAdd(_GM(errMenu), EM_TAG_RETURN, EM_RETURN_X, EM_RETURN_Y, EM_RETURN_W, EM_RETURN_H, cb_Err_Done);
// Configure the game so pressing <esc> will cause the menu to disappear and the gamemenu to reappear
- menu_Configure(_GM(errMenu), cb_Err_Done, cb_Err_Done);
+ guiMenu::configure(_GM(errMenu), cb_Err_Done, cb_Err_Done);
vmng_screen_show((void *)_GM(errMenu));
LockMouseSprite(0);
@@ -2270,7 +2270,7 @@ void UpdateThumbNails(int32 firstSlot, guiMenu *myMenu) {
if (!LoadThumbNail(i)) {
_GM(slotInUse)[i] = false;
menu_DisableButton(nullptr, 1001 + i - firstSlot, myMenu);
- menu_ItemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
+ guiMenu::itemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
}
}
}
@@ -2291,7 +2291,7 @@ void UpdateThumbNails(int32 firstSlot, guiMenu *myMenu) {
if (!LoadThumbNail(i)) {
_GM(slotInUse)[i] = false;
menu_DisableButton(nullptr, 1001 + i - firstSlot, myMenu);
- menu_ItemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
+ guiMenu::itemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
}
}
}
@@ -2315,7 +2315,7 @@ void SetFirstSlot(int32 firstSlot, guiMenu *myMenu) {
// Change the prompt and special tag of each of the slot buttons
for (i = 0; i < MAX_SLOTS_SHOWN; i++) {
- myButton = (menuItemButton *)menu_GetItem(i + 1001, myMenu);
+ myButton = (menuItemButton *)guiMenu::getItem(i + 1001, myMenu);
myButton->prompt = _GM(slotTitles)[firstSlot + i];
if (_GM(currMenuIsSave) || _GM(slotInUse)[firstSlot + i]) {
@@ -2325,7 +2325,7 @@ void SetFirstSlot(int32 firstSlot, guiMenu *myMenu) {
}
myButton->specialTag = firstSlot + i + 1;
- menu_ItemRefresh(myButton, i + 1001, myMenu);
+ guiMenu::itemRefresh(myButton, i + 1001, myMenu);
}
}
@@ -2382,7 +2382,7 @@ void cb_SaveLoad_VSlider(menuItemVSlider *myItem, guiMenu *myMenu) {
((myItem->percent * (myItem->maxThumbY - myItem->minThumbY)) / 100);
// Redraw the slider
- menu_ItemRefresh(myItem, -1, myMenu);
+ guiMenu::itemRefresh(myItem, -1, myMenu);
}
}
@@ -2404,7 +2404,7 @@ void cb_SaveLoad_Save(void *, guiMenu *myMenu) {
}
// First make the textfield NORM
- myText = (menuItemTextField *)menu_GetItem(2000, myMenu);
+ myText = (menuItemTextField *)guiMenu::getItem(2000, myMenu);
if (myText)
return;
@@ -2434,7 +2434,7 @@ void cb_SaveLoad_Save(void *, guiMenu *myMenu) {
DestroySaveLoadMenu(true);
// Shutdown the menu system
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
@@ -2450,7 +2450,7 @@ void cb_SaveLoad_Load(menuItemButton *, guiMenu *) {
DestroySaveLoadMenu(false);
// Shutdown the menu system
- menu_Shutdown(false);
+ guiMenu::shutdown(false);
// See if we need to reset the ESC, F2, and F3 hotkeys
if (_GM(gameMenuFromMain)) {
@@ -2479,19 +2479,19 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
for (i = 1001; i <= 1010; i++) {
if (_GM(currMenuIsSave) || _GM(slotInUse)[i - 1001 + _GM(firstSlotIndex)]) {
menu_EnableButton(nullptr, i, myMenu);
- menu_ItemRefresh(nullptr, i, myMenu);
+ guiMenu::itemRefresh(nullptr, i, myMenu);
}
}
// Find the textfield and use it's coords to place the button
- myItem = menu_GetItem(2000, myMenu);
+ myItem = guiMenu::getItem(2000, myMenu);
x = myItem->x1;
y = myItem->y1;
w = myItem->x2 - myItem->x1 + 1;
h = myItem->y2 - myItem->y1 + 1;
// Delete the textfield
- menu_ItemDelete(myItem, 2000, myMenu);
+ guiMenu::itemDelete(myItem, 2000, myMenu);
// Add the button back in
if (_GM(currMenuIsSave)) {
@@ -2506,22 +2506,22 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
// Remove the thumbnail
if (_GM(saveLoadThumbNail)) {
_GM(saveLoadThumbNail) = _GM(menuSprites)[SL_EMPTY_THUMB];
- menu_ItemRefresh(nullptr, SL_TAG_THUMBNAIL, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, myMenu);
}
}
SetFirstSlot(_GM(firstSlotIndex), myMenu);
// Enable the slider
menu_EnableVSlider(nullptr, SL_TAG_VSLIDER, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
// Disable the save/load button
if (_GM(currMenuIsSave)) {
menu_DisableButton(nullptr, SL_TAG_SAVE, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_SAVE, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
} else {
menu_DisableButton(nullptr, SL_TAG_LOAD, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_LOAD, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
}
// Reset the slot selected var
@@ -2535,7 +2535,7 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
if (_GM(saveLoadFromHotkey)) {
// Shutdown the menu system
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
} else {
// Create the game menu
CreateGameMenuMain(nullptr);
@@ -2567,7 +2567,7 @@ void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
for (i = 1001; i <= 1010; i++) {
if (i != myButton->tag) {
menu_DisableButton(nullptr, i, myMenu);
- menu_ItemRefresh(nullptr, i, myMenu);
+ guiMenu::itemRefresh(nullptr, i, myMenu);
}
}
@@ -2576,7 +2576,7 @@ void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
y = myButton->y1;
w = myButton->x2 - myButton->x1 + 1;
h = myButton->y2 - myButton->y1 + 1;
- menu_ItemDelete(myButton, -1, myMenu);
+ guiMenu::itemDelete(myButton, -1, myMenu);
if (_GM(currMenuIsSave)) {
// Replace the current button with a textfield
@@ -2594,15 +2594,15 @@ void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
// Disable the slider
menu_DisableVSlider(nullptr, SL_TAG_VSLIDER, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
// Enable the save/load button
if (_GM(currMenuIsSave)) {
menu_EnableButton(nullptr, SL_TAG_SAVE, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_SAVE, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
} else {
menu_EnableButton(nullptr, SL_TAG_LOAD, myMenu);
- menu_ItemRefresh(nullptr, SL_TAG_LOAD, myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
}
}
@@ -2648,7 +2648,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
// See if the current _GM(saveLoadThumbNail) is pointing to the correct sprite
if (_GM(saveLoadThumbNail) != _GM(thumbNails)[myItem->specialTag - 1]) {
_GM(saveLoadThumbNail) = _GM(thumbNails)[myItem->specialTag - 1];
- menu_ItemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
}
}
@@ -2666,7 +2666,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
// Remove the thumbnail
if (_GM(saveLoadThumbNail)) {
_GM(saveLoadThumbNail) = _GM(menuSprites)[SL_EMPTY_THUMB];
- menu_ItemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
+ guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
}
}
}
@@ -2702,10 +2702,10 @@ void DestroySaveLoadMenu(bool saveMenu) {
// Destroy the screen
vmng_screen_dispose(_GM(slMenu));
- menu_Destroy(_GM(slMenu));
+ guiMenu::destroy(_GM(slMenu));
// Unload the save/load menu sprites
- menu_UnloadSprites();
+ guiMenu::unloadSprites();
}
@@ -2714,7 +2714,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
bool buttonGreyed;
if (!_G(menuSystemInitialized)) {
- menu_Initialize(myPalette);
+ guiMenu::initialize(myPalette);
}
// Keep the memory tidy
@@ -2722,7 +2722,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
CompactMem();
// Load in the game menu sprites
- if (!menu_LoadSprites("slmenu", SL_TOTAL_SPRITES)) {
+ if (!guiMenu::loadSprites("slmenu", SL_TOTAL_SPRITES)) {
return;
}
@@ -2733,7 +2733,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
_GM(thumbIndex) = 100;
_GM(currMenuIsSave) = saveMenu;
- _GM(slMenu) = menu_Create(_GM(menuSprites)[SL_DIALOG_BOX], SAVE_LOAD_MENU_X, SAVE_LOAD_MENU_Y,
+ _GM(slMenu) = guiMenu::create(_GM(menuSprites)[SL_DIALOG_BOX], SAVE_LOAD_MENU_X, SAVE_LOAD_MENU_Y,
MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
if (!_GM(slMenu)) {
return;
@@ -2790,11 +2790,11 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
if (_GM(currMenuIsSave)) {
//<return> - if a slot has been selected, saves the game
//<esc> - cancels and returns to the game menu
- menu_Configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Save, (CALLBACK)cb_SaveLoad_Cancel);
+ guiMenu::configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Save, (CALLBACK)cb_SaveLoad_Cancel);
} else {
//<return> - if a slot has been selected, loads the selected game
//<esc> - cancels and returns to the game menu
- menu_Configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Load, (CALLBACK)cb_SaveLoad_Cancel);
+ guiMenu::configure(_GM(slMenu), (CALLBACK)cb_SaveLoad_Load, (CALLBACK)cb_SaveLoad_Cancel);
}
vmng_screen_show((void *)_GM(slMenu));
diff --git a/engines/m4/gui/gui_menu.cpp b/engines/m4/gui/gui_menu.cpp
index eef18c0f15a..a4a32ac12ec 100644
--- a/engines/m4/gui/gui_menu.cpp
+++ b/engines/m4/gui/gui_menu.cpp
@@ -42,11 +42,11 @@
namespace M4 {
namespace GUI {
-bool menu_Initialize(RGB8 *myPalette) {
+bool guiMenu::initialize(RGB8 *myPalette) {
int32 i, memAvail;
// This procedure is called before *any* menu is created - the following global var is used
- // By the menu_eventhandler() to trap events - it must be cleared.
+ // By the guiMenu::eventHandler() to trap events - it must be cleared.
_GM(menuCurrItem) = nullptr;
if (_G(menuSystemInitialized)) {
@@ -130,7 +130,7 @@ bool menu_Initialize(RGB8 *myPalette) {
return true;
}
-void menu_Shutdown(bool fadeToColor) {
+void guiMenu::shutdown(bool fadeToColor) {
int32 i;
// Verify that we need to shutdown
@@ -197,9 +197,7 @@ void menu_Shutdown(bool fadeToColor) {
_G(menuSystemInitialized) = false;
}
-bool menu_EventHandler(void *theMenu, int32 eventType, int32 parm1, int32 parm2, int32 parm3, bool *currScreen);
-
-GrBuff *menu_CopyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h) {
+GrBuff *guiMenu::copyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h) {
GrBuff *copyOfBackground;
Buffer *srcBuff, *destBuff;
@@ -233,7 +231,7 @@ GrBuff *menu_CopyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h)
return copyOfBackground;
}
-void menu_Show(void *s, void *r, void *b, int32 destX, int32 destY) {
+void guiMenu::show(void *s, void *r, void *b, int32 destX, int32 destY) {
ScreenContext *myScreen = (ScreenContext *)s;
RectList *myRectList = (RectList *)r;
Buffer *destBuffer = (Buffer *)b;
@@ -283,7 +281,7 @@ void menu_Show(void *s, void *r, void *b, int32 destX, int32 destY) {
myMenuBuffer->release();
}
-guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags) {
+guiMenu *guiMenu::create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags) {
guiMenu *newMenu;
Buffer *tempBuff, drawSpriteBuff;
DrawRequest spriteDrawReq;
@@ -299,7 +297,7 @@ guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFla
newMenu->itemList = nullptr;
newMenu->cb_return = nullptr;
newMenu->cb_esc = nullptr;
- newMenu->menuEventHandler = menu_EventHandler;
+ newMenu->menuEventHandler = (EventHandler)guiMenu::eventHandler;
// Draw the background in to the menuBuffer
tempBuff = newMenu->menuBuffer->get_buffer();
@@ -344,14 +342,14 @@ guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFla
newMenu->menuBuffer->release();
if (!vmng_screen_create(x1, y1, x1 + backgroundSprite->w - 1, y1 + backgroundSprite->h - 1, 69, scrnFlags, (void *)newMenu,
- (RefreshFunc)menu_Show, menu_EventHandler)) {
+ (RefreshFunc)guiMenu::show, (EventHandler)guiMenu::eventHandler)) {
return nullptr;
}
return newMenu;
}
-void menu_Destroy(guiMenu *myMenu) {
+void guiMenu::destroy(guiMenu *myMenu) {
menuItem *myItem;
// Verify params
@@ -374,7 +372,7 @@ void menu_Destroy(guiMenu *myMenu) {
delete myMenu;
}
-void menu_Configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc) {
+void guiMenu::configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc) {
if (!myMenu) {
return;
}
@@ -382,7 +380,7 @@ void menu_Configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc) {
myMenu->cb_esc = cb_esc;
}
-bool menu_EventHandler(void *theMenu, int32 eventType, int32 parm1, int32 parm2, int32 parm3, bool *currScreen) {
+bool guiMenu::eventHandler(guiMenu *theMenu, int32 eventType, int32 parm1, int32 parm2, int32 parm3, bool *currScreen) {
ScreenContext *myScreen;
guiMenu *myMenu = (guiMenu *)theMenu;
menuItem *myItem;
@@ -505,7 +503,7 @@ bool menu_EventHandler(void *theMenu, int32 eventType, int32 parm1, int32 parm2,
return true;
}
-menuItem *menu_GetItem(int32 tag, guiMenu *myMenu) {
+menuItem *guiMenu::getItem(int32 tag, guiMenu *myMenu) {
menuItem *myItem;
// Verify params
@@ -521,8 +519,7 @@ menuItem *menu_GetItem(int32 tag, guiMenu *myMenu) {
return myItem;
}
-
-void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu) {
+void guiMenu::itemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu) {
Buffer *myBuff, *backgroundBuff;
// Verify params
@@ -530,12 +527,10 @@ void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu) {
return;
}
- if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
- }
- if (!myItem) {
+ if (!myItem)
+ myItem = guiMenu::getItem(tag, myMenu);
+ if (!myItem)
return;
- }
// Remove myItem from the item list
if (myItem->next) {
@@ -577,7 +572,7 @@ void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu) {
}
}
-void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
+void guiMenu::itemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
ScreenContext *myScreen;
int32 status;
@@ -587,7 +582,7 @@ void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
}
if (!myItem) {
- myItem = menu_GetItem(tag, myMenu);
+ myItem = guiMenu::getItem(tag, myMenu);
}
if (!myItem) {
return;
@@ -607,7 +602,7 @@ void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
//----------------------------- GAME MENU FUNCTIONS ---------------------------------//
-bool menu_LoadSprites(const char *series, int32 numSprites) {
+bool guiMenu::loadSprites(const char *series, int32 numSprites) {
int32 i;
// Load in the game menu series
@@ -640,7 +635,7 @@ bool menu_LoadSprites(const char *series, int32 numSprites) {
return true;
}
-void menu_UnloadSprites() {
+void guiMenu::unloadSprites() {
int32 i;
if (!_GM(menuSeriesResource)) {
diff --git a/engines/m4/gui/gui_menu.h b/engines/m4/gui/gui_menu.h
index 57413b65527..5172c26132f 100644
--- a/engines/m4/gui/gui_menu.h
+++ b/engines/m4/gui/gui_menu.h
@@ -120,11 +120,29 @@ struct menuItemTextField : public menuItem {
};
struct guiMenu {
+private:
+ static void show(void *s, void *r, void *b, int32 destX, int32 destY);
+ static bool eventHandler(guiMenu *theMenu, int32 eventType, int32 parm1, int32 parm2, int32 parm3, bool *currScreen);
+
+public:
GrBuff *menuBuffer;
menuItem *itemList;
CALLBACK cb_return;
CALLBACK cb_esc;
EventHandler menuEventHandler;
+
+ static bool initialize(RGB8 *myPalette);
+ static void shutdown(bool fadeToColor);
+ static guiMenu *create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags);
+ static void destroy(guiMenu *myMenu);
+ static void configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc);
+ static GrBuff *copyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h);
+ static menuItem *getItem(int32 tag, guiMenu *myMenu);
+ static void itemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu);
+ static void itemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu);
+
+ static bool loadSprites(const char *series, int32 numSprites);
+ static void unloadSprites();
};
struct MenuGlobals {
@@ -189,20 +207,6 @@ struct MenuGlobals {
#define MAX_SLOTS 99 // number of save games you can have
#define MAX_SLOTS_SHOWN 8 // number of slots in the scrolling field
-// GENERAL MENU FUNCTIONS
-extern bool menu_Initialize(RGB8 *myPalette);
-extern void menu_Shutdown(bool fadeToColor);
-extern guiMenu *menu_Create(Sprite *backgroundSprite, int32 x1, int32 y1, int32 scrnFlags);
-extern void menu_Destroy(guiMenu *myMenu);
-extern void menu_Configure(guiMenu *myMenu, CALLBACK cb_return, CALLBACK cb_esc);
-extern GrBuff *menu_CopyBackground(guiMenu *myMenu, int32 x, int32 y, int32 w, int32 h);
-extern menuItem *menu_GetItem(int32 tag, guiMenu *myMenu);
-extern void menu_ItemDelete(menuItem *myItem, int32 tag, guiMenu *myMenu);
-extern void menu_ItemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu);
-
-extern bool menu_LoadSprites(const char *series, int32 numSprites);
-extern void menu_UnloadSprites();
-
} // namespace GUI
} // namespace M4
diff --git a/engines/m4/riddle/gui/game_menu.cpp b/engines/m4/riddle/gui/game_menu.cpp
index bd87054d0f8..966e4f95b12 100644
--- a/engines/m4/riddle/gui/game_menu.cpp
+++ b/engines/m4/riddle/gui/game_menu.cpp
@@ -64,7 +64,7 @@ namespace GUI {
void GameMenu::show(RGB8 *myPalette) {
if (!_G(menuSystemInitialized)) {
- menu_Initialize(myPalette);
+ guiMenu::initialize(myPalette);
}
// Keep the memory tidy
@@ -72,11 +72,11 @@ void GameMenu::show(RGB8 *myPalette) {
CompactMem();
// Load in the game menu sprites
- if (!menu_LoadSprites("gamemenu", GM_TOTAL_SPRITES)) {
+ if (!guiMenu::loadSprites("gamemenu", GM_TOTAL_SPRITES)) {
return;
}
- _GM(gameMenu) = menu_Create(_GM(menuSprites)[GM_DIALOG_BOX],
+ _GM(gameMenu) = guiMenu::create(_GM(menuSprites)[GM_DIALOG_BOX],
GAME_MENU_X, GAME_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
assert(_GM(gameMenu));
@@ -103,7 +103,7 @@ void GameMenu::show(RGB8 *myPalette) {
}
#endif
// Configure the game so pressing <esc> will cause the menu to disappear and the game to resume
- menu_Configure(_GM(gameMenu), cbResume, cbResume);
+ guiMenu::configure(_GM(gameMenu), cbResume, cbResume);
vmng_screen_show((void *)_GM(gameMenu));
LockMouseSprite(0);
@@ -118,10 +118,10 @@ void GameMenu::DestroyGameMenu() {
vmng_screen_dispose(_GM(gameMenu));
// Destroy the menu resources
- menu_Destroy(_GM(gameMenu));
+ guiMenu::destroy(_GM(gameMenu));
// Unload the menu sprites
- menu_UnloadSprites();
+ guiMenu::unloadSprites();
}
void GameMenu::cbQuitGame(void *, void *) {
@@ -129,7 +129,7 @@ void GameMenu::cbQuitGame(void *, void *) {
DestroyGameMenu();
// Shutdown the menu system
- menu_Shutdown(false);
+ guiMenu::shutdown(false);
// Set the global that will cause the entire game to exit to dos
_G(kernel).going = false;
@@ -149,9 +149,9 @@ void GameMenu::cbMainMenu(void *, void *) {
_GM(interfaceWasVisible) = false;
// Shutdown the menu system
- menu_Shutdown(false);
+ guiMenu::shutdown(false);
} else {
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
// Go to the main menu
@@ -163,7 +163,7 @@ void GameMenu::cbResume(void *, void *) {
DestroyGameMenu();
// Shutdown the menu system
- menu_Shutdown(true);
+ guiMenu::shutdown(true);
}
/*-------------------- ACCESS METHODS --------------------*/
Commit: 05a0941d2daf7982b55095b9e59af957f9e79ec9
https://github.com/scummvm/scummvm/commit/05a0941d2daf7982b55095b9e59af957f9e79ec9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-12T21:26:10-08:00
Commit Message:
M4: BURGER: Move button methods to menuItemButton class
Changed paths:
engines/m4/burger/gui/game_menu.cpp
engines/m4/burger/gui/game_menu.h
engines/m4/gui/gui_menu.cpp
engines/m4/gui/gui_menu.h
engines/m4/riddle/gui/game_menu.cpp
diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index c03bec951d5..a8455c4761f 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -235,66 +235,6 @@ Sprite *menu_CreateThumbnail(int32 *spriteSize) {
return thumbNailSprite;
}
-
-bool menu_CursorInsideItem(menuItem *myItem, int32 cursorX, int32 cursorY) {
- if ((cursorX >= myItem->x1) && (cursorX <= myItem->x2) && (cursorY >= myItem->y1) && (cursorY <= myItem->y2)) {
- return true;
- } else {
- return false;
- }
-}
-
-
-void gui_DrawSprite(Sprite *mySprite, Buffer *myBuff, int32 x, int32 y) {
- DrawRequest spriteDrawReq;
- Buffer drawSpriteBuff;
-
- if ((!mySprite) || (!myBuff)) {
- return;
- }
-
- if (mySprite->sourceHandle) {
- HLock(mySprite->sourceHandle);
- mySprite->data = (uint8 *)((intptr)*(mySprite->sourceHandle) + mySprite->sourceOffset);
-
- drawSpriteBuff.w = mySprite->w;
- drawSpriteBuff.stride = mySprite->w;
- drawSpriteBuff.h = mySprite->h;
- drawSpriteBuff.encoding = (mySprite->encoding) & (uint8)0x7f;
- drawSpriteBuff.data = mySprite->data;
-
- spriteDrawReq.Src = &drawSpriteBuff;
- spriteDrawReq.Dest = myBuff;
- spriteDrawReq.x = x;
- spriteDrawReq.y = y;
- spriteDrawReq.scaleX = 100;
- spriteDrawReq.scaleY = 100;
- spriteDrawReq.srcDepth = 0;
- spriteDrawReq.depthCode = nullptr;
- spriteDrawReq.Pal = nullptr;
- spriteDrawReq.ICT = nullptr;
-
- gr_sprite_draw(&spriteDrawReq);
-
- // Unlock the handle
- HUnLock(mySprite->sourceHandle);
- }
-}
-
-
-void item_Destroy(menuItem *theItem) {
- // Verify params
- if (!theItem) {
- return;
- }
- if (theItem->background) {
- delete theItem->background;
- }
-
- delete theItem;
-}
-
-
//------------------------------- MESSAGE MENU ITEM ---------------------------------//
@@ -323,10 +263,10 @@ void menu_DrawMsg(menuItemMsg *myItem, guiMenu *myMenu, int32 x, int32 y, int32,
//myMsg = (menuItemMsg *)myItem->itemInfo;
switch (myItem->tag) {
case SL_TAG_SAVE_LABEL:
- mySprite = _GM(menuSprites)[SL_SAVE_LABEL];
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_SAVE_LABEL];
break;
case SL_TAG_LOAD_LABEL:
- mySprite = _GM(menuSprites)[SL_LOAD_LABEL];
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LOAD_LABEL];
break;
case SL_TAG_THUMBNAIL:
mySprite = _GM(saveLoadThumbNail);
@@ -400,7 +340,7 @@ menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
}
newItem->redraw = (DrawFunction)menu_DrawMsg;
- newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->destroy = (DestroyFunction)menuItem::destroyItem;
newItem->itemEventHandler = nullptr;
// Draw the message in now
@@ -416,449 +356,6 @@ menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w,
return newItem;
}
-
-
-//------------------------------- BUTTON MENU ITEM ----------------------------------//
-
-enum button_states {
- BTN_STATE_NORM = 0,
- BTN_STATE_OVER = 1,
- BTN_STATE_PRESS = 2,
- BTN_STATE_GREY = 3
-};
-
-enum button_types {
- BTN_TYPE_GM_GENERIC,
- BTN_TYPE_SL_SAVE,
- BTN_TYPE_SL_LOAD,
- BTN_TYPE_SL_CANCEL,
- BTN_TYPE_SL_TEXT,
- BTN_TYPE_OM_DONE,
- BTN_TYPE_OM_CANCEL,
-
- BTN_TYPE_TOTAL_NUMBER
-};
-
-
-void menu_DrawButton(menuItemButton *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
- Buffer *myBuff = nullptr;
- Buffer *backgroundBuff = nullptr;
- Sprite *mySprite = nullptr;
- char tempStr[32];
-
- // Verify params
- if (!myItem || !myMenu) {
- return;
- }
-
- // If the item is marked transparent, get the background buffer
- if (myItem->transparent) {
- if (!myItem->background) {
- return;
- }
- backgroundBuff = myItem->background->get_buffer();
- if (!backgroundBuff) {
- return;
- }
- }
-
- // Select the sprite
- switch (myItem->buttonType) {
- case BTN_TYPE_GM_GENERIC:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[GM_BUTTON_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[GM_BUTTON_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[GM_BUTTON_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[GM_BUTTON_GREY];
- break;
- }
- break;
-
- case BTN_TYPE_SL_SAVE:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[SL_SAVE_BTN_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[SL_SAVE_BTN_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[SL_SAVE_BTN_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[SL_SAVE_BTN_GREY];
- break;
- }
- break;
-
- case BTN_TYPE_SL_LOAD:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[SL_LOAD_BTN_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[SL_LOAD_BTN_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[SL_LOAD_BTN_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[SL_LOAD_BTN_GREY];
- break;
- }
- break;
-
- case BTN_TYPE_SL_TEXT:
- switch (myItem->itemFlags) {
- case BTN_STATE_OVER:
- font_set_colors(TEXT_COLOR_OVER_SHADOW, TEXT_COLOR_OVER_FOREGROUND, TEXT_COLOR_OVER_HILITE);
- // Gr_font_set_color(TEXT_COLOR_OVER);
- mySprite = _GM(menuSprites)[SL_LINE_OVER];
- break;
- case BTN_STATE_PRESS:
- font_set_colors(TEXT_COLOR_PRESS_SHADOW, TEXT_COLOR_PRESS_FOREGROUND, TEXT_COLOR_PRESS_HILITE);
- // Gr_font_set_color(TEXT_COLOR_PRESS);
- mySprite = _GM(menuSprites)[SL_LINE_PRESS];
- break;
- case BTN_STATE_GREY:
- font_set_colors(TEXT_COLOR_GREY_SHADOW, TEXT_COLOR_GREY_FOREGROUND, TEXT_COLOR_GREY_HILITE);
- // Gr_font_set_color(TEXT_COLOR_GREY);
- mySprite = _GM(menuSprites)[SL_LINE_NORM];
- break;
- default:
- case BTN_STATE_NORM:
- font_set_colors(TEXT_COLOR_NORM_SHADOW, TEXT_COLOR_NORM_FOREGROUND, TEXT_COLOR_NORM_HILITE);
- // Gr_font_set_color(TEXT_COLOR_NORM);
- mySprite = _GM(menuSprites)[SL_LINE_NORM];
- break;
- }
- break;
-
- case BTN_TYPE_SL_CANCEL:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[SL_CANCEL_BTN_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[SL_CANCEL_BTN_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[SL_CANCEL_BTN_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[SL_CANCEL_BTN_NORM];
- break;
- }
- break;
-
- case BTN_TYPE_OM_DONE:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[OM_DONE_BTN_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[OM_DONE_BTN_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[OM_DONE_BTN_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[OM_DONE_BTN_GREY];
- break;
- }
- break;
-
- case BTN_TYPE_OM_CANCEL:
- switch (myItem->itemFlags) {
- case BTN_STATE_NORM:
- mySprite = _GM(menuSprites)[OM_CANCEL_BTN_NORM];
- break;
- case BTN_STATE_OVER:
- mySprite = _GM(menuSprites)[OM_CANCEL_BTN_OVER];
- break;
- case BTN_STATE_PRESS:
- mySprite = _GM(menuSprites)[OM_CANCEL_BTN_PRESS];
- break;
- default:
- case BTN_STATE_GREY:
- mySprite = _GM(menuSprites)[OM_CANCEL_BTN_NORM];
- break;
- }
- break;
- }
-
- // Get the menu buffer
- myBuff = myMenu->menuBuffer->get_buffer();
- if (!myBuff) {
- return;
- }
-
- // If the item is tagged as transparent, we need to fill in it's background behind it
- if (backgroundBuff) {
- gr_buffer_rect_copy_2(backgroundBuff, myBuff, 0, 0, x, y, backgroundBuff->w, backgroundBuff->h);
- myItem->background->release();
- }
-
- // Draw the button sprite in
- gui_DrawSprite(mySprite, myBuff, x, y);
-
- // If the button is a textbutton, write in the text
- if ((myItem->buttonType == BTN_TYPE_SL_TEXT) && (myItem->prompt)) {
- // Write in the special tag
- Common::sprintf_s(tempStr, 32, "%02d", myItem->tag - 1000 + _GM(firstSlotIndex));
-
- gr_font_set(_GM(menuFont));
- gr_font_write(myBuff, tempStr, x + 4, y + 1, 0, -1);
- gr_font_write(myBuff, myItem->prompt, x + 26, y + 1, 0, -1);
- }
-
- // Release the menu buffer
- myMenu->menuBuffer->release();
-}
-
-
-bool button_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
- bool redrawItem, execCallback, handled;
- ScreenContext *myScreen;
- int32 status;
- int32 currTag;
- guiMenu *currMenu;
- menuItem *tempItem;
-
- // Verify params
- if (!myItem) {
- return false;
- }
-
- if (!(eventType == EVENT_MOUSE)) {
- return false;
- }
-
- if (myItem->itemFlags == BTN_STATE_GREY) {
- return false;
- }
-
- redrawItem = false;
- execCallback = false;
- handled = true;
-
- switch (event) {
- case _ME_L_click:
- case _ME_doubleclick:
- if (menu_CursorInsideItem(myItem, x, y)) {
- myItem->itemFlags = BTN_STATE_PRESS;
- *currItem = myItem;
- redrawItem = true;
- } else {
- *currItem = nullptr;
- if (myItem->itemFlags != BTN_STATE_NORM) {
- myItem->itemFlags = BTN_STATE_NORM;
- redrawItem = true;
- }
- }
- break;
-
- case _ME_L_drag:
- case _ME_doubleclick_drag:
- if (!*currItem) {
- return true;
- }
- if (menu_CursorInsideItem(myItem, x, y)) {
- if (myItem->itemFlags != BTN_STATE_PRESS) {
- myItem->itemFlags = BTN_STATE_PRESS;
- redrawItem = true;
- }
- } else {
- if (myItem->itemFlags != BTN_STATE_OVER) {
- myItem->itemFlags = BTN_STATE_OVER;
- redrawItem = true;
- }
- }
- break;
-
- case _ME_L_release:
- case _ME_doubleclick_release:
- if (menu_CursorInsideItem(myItem, x, y)) {
- if (*currItem) {
- execCallback = true;
- } else {
- *currItem = myItem;
- }
- myItem->itemFlags = BTN_STATE_OVER;
- redrawItem = true;
- } else {
- *currItem = nullptr;
- myItem->itemFlags = BTN_STATE_NORM;
- redrawItem = true;
- handled = false;
- }
- break;
-
- case _ME_move:
- if (menu_CursorInsideItem(myItem, x, y)) {
- *currItem = myItem;
- if (myItem->itemFlags != BTN_STATE_OVER) {
- myItem->itemFlags = BTN_STATE_OVER;
- redrawItem = true;
- }
- } else {
- *currItem = nullptr;
- if (myItem->itemFlags != BTN_STATE_NORM) {
- myItem->itemFlags = BTN_STATE_NORM;
- redrawItem = true;
- handled = false;
- }
- }
- break;
-
- case _ME_L_hold:
- case _ME_doubleclick_hold:
- break;
- }
-
- // See if we need to redraw the button
- if (redrawItem) {
- (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
- myScreen = vmng_screen_find(myItem->myMenu, &status);
- if (myScreen && (status == SCRN_ACTIVE)) {
- RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
- myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
- }
- }
-
- // See if we need to call the callback function
- if (execCallback && myItem->callback) {
- // digi_play(inv_click_snd, 2, 255, -1, inv_click_snd_room_lock);
- currMenu = (guiMenu *)myItem->myMenu;
- currTag = myItem->tag;
- buttonClosesDialog = false;
-
- (myItem->callback)((void *)myItem, myItem->myMenu);
-
- status = 0;
- myScreen = buttonClosesDialog ? nullptr : vmng_screen_find(myItem->myMenu, &status);
-
- if ((!myScreen) || (status != SCRN_ACTIVE)) {
- *currItem = nullptr;
- } else {
- tempItem = guiMenu::getItem(currTag, currMenu);
- if (!tempItem) {
- *currItem = nullptr;
- }
- }
- }
-
- return handled;
-}
-
-
-menuItemButton *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback, int32 buttonType,
- bool greyed, bool transparent, const char *prompt, ItemHandlerFunction i_handler) {
- menuItemButton *newItem;
- ScreenContext *myScreen;
- int32 status;
-
- // Verify params
- if (!myMenu) {
- return nullptr;
- }
-
- // Allocate a new one
- newItem = new menuItemButton();
-
- // Initialize the struct
- newItem->next = myMenu->itemList;
- newItem->prev = nullptr;
- if (myMenu->itemList) {
- myMenu->itemList->prev = newItem;
- }
- myMenu->itemList = newItem;
-
- newItem->myMenu = myMenu;
- newItem->tag = tag;
- newItem->x1 = x;
- newItem->y1 = y;
- newItem->x2 = x + w - 1;
- newItem->y2 = y + h - 1;
- newItem->callback = callback;
-
- if (!transparent) {
- newItem->transparent = false;
- newItem->background = nullptr;
- } else {
- newItem->transparent = true;
- newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
- }
-
- if (greyed) {
- newItem->itemFlags = BTN_STATE_GREY;
- } else {
- newItem->itemFlags = BTN_STATE_NORM;
- }
- newItem->buttonType = buttonType;
-
- // Note: prompt is not duplicated, therefore, make sure the name is stored in non-volatile memory
- newItem->prompt = prompt;
- newItem->specialTag = tag - 1000;
-
- newItem->redraw = (DrawFunction)menu_DrawButton;
- newItem->destroy = (DestroyFunction)item_Destroy;
- newItem->itemEventHandler = i_handler;
-
- // Draw the button in now
- (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
-
- // See if the screen is currently visible
- myScreen = vmng_screen_find(myMenu, &status);
- if (myScreen && (status == SCRN_ACTIVE)) {
- RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
- myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
- }
-
- return newItem;
-}
-
-
-void menu_DisableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
- // Verify params
- if (!myMenu)
- return;
-
- if (!myItem)
- myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
- if (!myItem)
- return;
-
- myItem->itemFlags = BTN_STATE_GREY;
-}
-
-
-void menu_EnableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
- // Verify params
- if (!myMenu)
- return;
-
- if (!myItem)
- myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
- if (!myItem)
- return;
-
- myItem->itemFlags = BTN_STATE_NORM;
-}
-
-
//------------------------------- HSLIDER MENU ITEM ---------------------------------//
enum {
@@ -916,7 +413,7 @@ void menu_DrawHSlider(menuItemHSlider *myItem, guiMenu *myMenu, int32 x, int32 y
// Fill in everything left of the thumb with a hilite color
if (myItem->thumbX > 2) {
- gr_color_set(SLIDER_BAR_COLOR);
+ gr_color_set(menuItem::SLIDER_BAR_COLOR);
gr_buffer_rect_fill(myBuff, myItem->x1 + 3, myItem->y1 + 9, myItem->thumbX, myItem->thumbH - 18);
}
@@ -951,7 +448,7 @@ bool hslider_Handler(menuItemHSlider *myItem, int32 eventType, int32 event, int3
switch (event) {
case _ME_L_click:
case _ME_doubleclick:
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ if (menuItem::cursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
(x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
myItem->itemFlags = H_THUMB_PRESS;
movingFlag = true;
@@ -1005,7 +502,7 @@ bool hslider_Handler(menuItemHSlider *myItem, int32 eventType, int32 event, int3
return true;
}
movingFlag = false;
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ if (menuItem::cursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
(x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
myItem->itemFlags = H_THUMB_OVER;
*currItem = myItem;
@@ -1018,7 +515,7 @@ bool hslider_Handler(menuItemHSlider *myItem, int32 eventType, int32 event, int3
break;
case _ME_move:
- if (menu_CursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
+ if (menuItem::cursorInsideItem(myItem, x, y) && (x - myItem->x1 >= myItem->thumbX) &&
(x - myItem->x1 <= myItem->thumbX + myItem->thumbW - 1)) {
if (myItem->itemFlags != H_THUMB_OVER) {
myItem->itemFlags = H_THUMB_OVER;
@@ -1118,7 +615,7 @@ menuItemHSlider *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, i
newItem->thumbX = initPercent * newItem->maxThumbX / 100;
newItem->redraw = (DrawFunction)menu_DrawHSlider;
- newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->destroy = (DestroyFunction)menuItem::destroyItem;
newItem->itemEventHandler = (ItemHandlerFunction)hslider_Handler;
// Draw the slider in now
@@ -1188,30 +685,30 @@ void menu_DrawVSlider(menuItemVSlider *myItem, guiMenu *myMenu, int32 x, int32 y
}
// Set the different sprite components
- vbarSprite = _GM(menuSprites)[SL_SCROLL_BAR];
- upSprite = _GM(menuSprites)[SL_UP_BTN_NORM];
- thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_NORM];
- downSprite = _GM(menuSprites)[SL_DOWN_BTN_NORM];
+ vbarSprite = _GM(menuSprites)[Burger::GUI::SL_SCROLL_BAR];
+ upSprite = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_NORM];
+ thumbSprite = _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_NORM];
+ downSprite = _GM(menuSprites)[Burger::GUI::SL_DOWN_BTN_NORM];
if ((myItem->itemFlags & VS_STATUS) == VS_GREY) {
- upSprite = _GM(menuSprites)[SL_UP_BTN_GREY];
+ upSprite = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_GREY];
thumbSprite = nullptr;
- downSprite = _GM(menuSprites)[SL_DOWN_BTN_GREY];
+ downSprite = _GM(menuSprites)[Burger::GUI::SL_DOWN_BTN_GREY];
} else if ((myItem->itemFlags & VS_STATUS) == VS_OVER) {
if ((myItem->itemFlags & VS_COMPONENT) == VS_UP) {
- upSprite = _GM(menuSprites)[SL_UP_BTN_OVER];
+ upSprite = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_OVER];
} else if ((myItem->itemFlags & VS_COMPONENT) == VS_THUMB) {
- thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_OVER];
+ thumbSprite = _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_OVER];
} else if ((myItem->itemFlags & VS_COMPONENT) == VS_DOWN) {
- downSprite = _GM(menuSprites)[SL_DOWN_BTN_OVER];
+ downSprite = _GM(menuSprites)[Burger::GUI::SL_DOWN_BTN_OVER];
}
} else if ((myItem->itemFlags & VS_STATUS) == VS_PRESS) {
if ((myItem->itemFlags & VS_COMPONENT) == VS_UP) {
- upSprite = _GM(menuSprites)[SL_UP_BTN_PRESS];
+ upSprite = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_PRESS];
} else if ((myItem->itemFlags & VS_COMPONENT) == VS_THUMB) {
- thumbSprite = _GM(menuSprites)[SL_SLIDER_BTN_PRESS];
+ thumbSprite = _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_PRESS];
} else if ((myItem->itemFlags & VS_COMPONENT) == VS_DOWN) {
- downSprite = _GM(menuSprites)[SL_DOWN_BTN_PRESS];
+ downSprite = _GM(menuSprites)[Burger::GUI::SL_DOWN_BTN_PRESS];
}
}
@@ -1270,7 +767,7 @@ bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int3
switch (event) {
case _ME_L_click:
case _ME_doubleclick:
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
// digi_play(inv_click_snd, 2, 255, -1, inv_click_snd_room_lock);
*currItem = myItem;
tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
@@ -1324,7 +821,7 @@ bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int3
movingY = myItem->thumbY + myItem->thumbH - 1 + myItem->y1;
}
} else {
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if ((myItem->itemFlags & VS_COMPONENT) == tempFlags) {
if ((tempFlags != VS_PAGE_UP) && (tempFlags != VS_PAGE_DOWN) &&
@@ -1354,7 +851,7 @@ bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int3
case _ME_L_release:
case _ME_doubleclick_release:
movingFlag = false;
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if ((tempFlags == VS_PAGE_UP) || (tempFlags == VS_PAGE_DOWN)) {
myItem->itemFlags = VS_NORM;
@@ -1373,7 +870,7 @@ bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int3
break;
case _ME_move:
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
*currItem = myItem;
tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if ((myItem->itemFlags & VS_COMPONENT) != tempFlags) {
@@ -1399,7 +896,7 @@ bool vslider_Handler(menuItemVSlider *myItem, int32 eventType, int32 event, int3
if (!*currItem) {
return true;
}
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
tempFlags = vslider_WhereIsCursor(myItem, y - myItem->y1);
if ((myItem->itemFlags & VS_COMPONENT) == tempFlags) {
if (currTime - callbackTime > 6) {
@@ -1473,12 +970,12 @@ menuItemVSlider *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, i
newItem->itemFlags = VS_NORM;
- newItem->thumbW = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->w;
- newItem->thumbH = _GM(menuSprites)[SL_SLIDER_BTN_NORM]->h;
+ newItem->thumbW = _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_NORM]->w;
+ newItem->thumbH = _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_NORM]->h;
- newItem->minThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + 1;
- newItem->maxThumbY = _GM(menuSprites)[SL_UP_BTN_NORM]->h + _GM(menuSprites)[SL_SCROLL_BAR]->h
- - _GM(menuSprites)[SL_SLIDER_BTN_NORM]->h - 1;
+ newItem->minThumbY = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_NORM]->h + 1;
+ newItem->maxThumbY = _GM(menuSprites)[Burger::GUI::SL_UP_BTN_NORM]->h + _GM(menuSprites)[Burger::GUI::SL_SCROLL_BAR]->h
+ - _GM(menuSprites)[Burger::GUI::SL_SLIDER_BTN_NORM]->h - 1;
// Calculate the initial thumbY
newItem->percent = imath_max(imath_min(initPercent, 100), 0);
@@ -1486,7 +983,7 @@ menuItemVSlider *menu_VSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, i
((newItem->percent * (newItem->maxThumbY - newItem->minThumbY)) / 100);
newItem->redraw = (DrawFunction)menu_DrawVSlider;
- newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->destroy = (DestroyFunction)menuItem::destroyItem;
newItem->itemEventHandler = (ItemHandlerFunction)vslider_Handler;
// Draw the vslider in now
@@ -1565,16 +1062,16 @@ void menu_DrawTextField(menuItemTextField *myItem, guiMenu *myMenu, int32 x, int
// Select the sprite
switch (myText->itemFlags) {
case TF_GREY:
- mySprite = _GM(menuSprites)[SL_LINE_NORM];
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_NORM];
break;
case TF_OVER:
- mySprite = _GM(menuSprites)[SL_LINE_OVER];
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_OVER];
break;
case TF_NORM:
default:
- mySprite = _GM(menuSprites)[SL_LINE_OVER];
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_OVER];
break;
}
@@ -1594,7 +1091,7 @@ void menu_DrawTextField(menuItemTextField *myItem, guiMenu *myMenu, int32 x, int
gui_DrawSprite(mySprite, myBuff, x, y);
//write in the special tag
- gr_font_set_color(TEXT_COLOR_NORM_FOREGROUND);
+ gr_font_set_color(menuItem::TEXT_COLOR_NORM_FOREGROUND);
Common::sprintf_s(tempStr, 64, "%02d", myText->specialTag);
gr_font_set(_GM(menuFont));
gr_font_write(myBuff, tempStr, x + 4, y + 1, 0, -1);
@@ -1610,7 +1107,7 @@ void menu_DrawTextField(menuItemTextField *myItem, guiMenu *myMenu, int32 x, int
cursorX = gr_font_string_width(&myText->prompt[0], -1);
*myText->cursor = tempChar;
- gr_color_set(TEXT_COLOR_OVER_FOREGROUND);
+ gr_color_set(menuItem::TEXT_COLOR_OVER_FOREGROUND);
gr_vline(myBuff, x + cursorX + 26, y + 1, y + 12);
}
}
@@ -1643,7 +1140,7 @@ bool textfield_Handler(menuItemTextField *myItem, int32 eventType, int32 event,
case _ME_L_click:
case _ME_doubleclick:
_GM(deleteSaveDesc) = false;
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
*currItem = myItem;
}
break;
@@ -1658,7 +1155,7 @@ bool textfield_Handler(menuItemTextField *myItem, int32 eventType, int32 event,
return true;
}
*currItem = nullptr;
- if (menu_CursorInsideItem(myItem, x, y)) {
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
if (myItem->itemFlags == TF_OVER) {
temp = strlen(myItem->prompt);
if (temp > 0) {
@@ -1850,7 +1347,7 @@ menuItemTextField *menu_TextFieldAdd(guiMenu *myMenu, int32 tag, int32 x, int32
textInfo->cursor = textInfo->promptEnd;
newItem->redraw = (DrawFunction)menu_DrawTextField;
- newItem->destroy = (DestroyFunction)item_Destroy;
+ newItem->destroy = (DestroyFunction)menuItem::destroyItem;
newItem->itemEventHandler = (ItemHandlerFunction)textfield_Handler;
// Draw the vslider in now
@@ -2012,22 +1509,22 @@ void CreateGameMenuMain(RGB8 *myPalette) {
return;
}
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_MAIN, GM_MAIN_X, GM_MAIN_Y, GM_MAIN_W, GM_MAIN_H, cb_Game_Main);
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cb_Game_Options);
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cb_Game_Resume);
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_QUIT, GM_QUIT_X, GM_QUIT_Y, GM_QUIT_W, GM_QUIT_H, cb_Game_Quit);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_MAIN, GM_MAIN_X, GM_MAIN_Y, GM_MAIN_W, GM_MAIN_H, cb_Game_Main);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cb_Game_Options);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cb_Game_Resume);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_QUIT, GM_QUIT_X, GM_QUIT_Y, GM_QUIT_W, GM_QUIT_H, cb_Game_Quit);
if (!_GM(gameMenuFromMain)) {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save);
} else {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save, menuItemButton::BTN_TYPE_GM_GENERIC, true);
}
// See if there are any games to load
if (g_engine->savesExist()) {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load);
} else {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load, menuItemButton::BTN_TYPE_GM_GENERIC, true);
}
// Configure the game so pressing <esc> will cause the menu to disappear and the game to resume
@@ -2071,7 +1568,7 @@ void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
term_message("digi volume: %d", myItem->percent);
// This scroller control has been moved, so make sure that the DONE button is not greyed out
- menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
+ menuItemButton::enableButton(nullptr, OM_TAG_DONE, myMenu);
guiMenu::itemRefresh(nullptr, OM_TAG_DONE, myMenu);
}
@@ -2081,7 +1578,7 @@ void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
_G(flags)[digestability] = myItem->percent;
// This scroller control has been moved, so make sure that the DONE button is not greyed out
- menu_EnableButton(nullptr, OM_TAG_DONE, myMenu);
+ menuItemButton::enableButton(nullptr, OM_TAG_DONE, myMenu);
guiMenu::itemRefresh(nullptr, OM_TAG_DONE, myMenu);
}
@@ -2119,8 +1616,8 @@ void CreateOptionsMenu(RGB8 *myPalette) {
return;
}
- menu_ButtonAdd(_GM(opMenu), OM_TAG_CANCEL, OM_CANCEL_X, OM_CANCEL_Y, OM_CANCEL_W, OM_CANCEL_H, cb_Options_Game_Cancel, BTN_TYPE_OM_CANCEL);
- menu_ButtonAdd(_GM(opMenu), OM_TAG_DONE, OM_DONE_X, OM_DONE_Y, OM_DONE_W, OM_DONE_H, cb_Options_Game_Done, BTN_TYPE_OM_DONE, true);
+ menuItemButton::buttonAdd(_GM(opMenu), OM_TAG_CANCEL, OM_CANCEL_X, OM_CANCEL_Y, OM_CANCEL_W, OM_CANCEL_H, cb_Options_Game_Cancel, menuItemButton::BTN_TYPE_OM_CANCEL);
+ menuItemButton::buttonAdd(_GM(opMenu), OM_TAG_DONE, OM_DONE_X, OM_DONE_Y, OM_DONE_W, OM_DONE_H, cb_Options_Game_Done, menuItemButton::BTN_TYPE_OM_DONE, true);
menu_HSliderAdd(_GM(opMenu), OM_TAG_DIGI, OM_DIGI_X, OM_DIGI_Y, OM_DIGI_W, OM_DIGI_H, digi_get_overall_volume(),
(CALLBACK)cb_Options_Digi, true);
menu_HSliderAdd(_GM(opMenu), OM_TAG_DIGESTABILITY, OM_DIGESTABILITY_X, OM_DIGESTABILITY_Y,
@@ -2197,7 +1694,7 @@ void CreateErrMenu(RGB8 *myPalette) {
}
//write the err message
- gr_font_set_color(TEXT_COLOR_NORM_FOREGROUND);
+ gr_font_set_color(menuItem::TEXT_COLOR_NORM_FOREGROUND);
gr_font_write(myBuff, "Save game failed!", 48, 8, 0, -1);
gr_font_write(myBuff, "A disk error has", 48, 23, 0, -1);
@@ -2211,7 +1708,7 @@ void CreateErrMenu(RGB8 *myPalette) {
_GM(errMenu)->menuBuffer->release();
// Add the done button
- menu_ButtonAdd(_GM(errMenu), EM_TAG_RETURN, EM_RETURN_X, EM_RETURN_Y, EM_RETURN_W, EM_RETURN_H, cb_Err_Done);
+ menuItemButton::buttonAdd(_GM(errMenu), EM_TAG_RETURN, EM_RETURN_X, EM_RETURN_Y, EM_RETURN_W, EM_RETURN_H, cb_Err_Done);
// Configure the game so pressing <esc> will cause the menu to disappear and the gamemenu to reappear
guiMenu::configure(_GM(errMenu), cb_Err_Done, cb_Err_Done);
@@ -2269,7 +1766,7 @@ void UpdateThumbNails(int32 firstSlot, guiMenu *myMenu) {
if (_GM(slotInUse)[i]) {
if (!LoadThumbNail(i)) {
_GM(slotInUse)[i] = false;
- menu_DisableButton(nullptr, 1001 + i - firstSlot, myMenu);
+ menuItemButton::disableButton(nullptr, 1001 + i - firstSlot, myMenu);
guiMenu::itemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
}
}
@@ -2290,7 +1787,7 @@ void UpdateThumbNails(int32 firstSlot, guiMenu *myMenu) {
if (_GM(slotInUse)[i]) {
if (!LoadThumbNail(i)) {
_GM(slotInUse)[i] = false;
- menu_DisableButton(nullptr, 1001 + i - firstSlot, myMenu);
+ menuItemButton::disableButton(nullptr, 1001 + i - firstSlot, myMenu);
guiMenu::itemRefresh(nullptr, 1001 + i - firstSlot, myMenu);
}
}
@@ -2319,9 +1816,9 @@ void SetFirstSlot(int32 firstSlot, guiMenu *myMenu) {
myButton->prompt = _GM(slotTitles)[firstSlot + i];
if (_GM(currMenuIsSave) || _GM(slotInUse)[firstSlot + i]) {
- myButton->itemFlags = BTN_STATE_NORM;
+ myButton->itemFlags = menuItemButton::BTN_STATE_NORM;
} else {
- myButton->itemFlags = BTN_STATE_GREY;
+ myButton->itemFlags = menuItemButton::BTN_STATE_GREY;
}
myButton->specialTag = firstSlot + i + 1;
@@ -2478,7 +1975,7 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
// Enable the prev buttons
for (i = 1001; i <= 1010; i++) {
if (_GM(currMenuIsSave) || _GM(slotInUse)[i - 1001 + _GM(firstSlotIndex)]) {
- menu_EnableButton(nullptr, i, myMenu);
+ menuItemButton::enableButton(nullptr, i, myMenu);
guiMenu::itemRefresh(nullptr, i, myMenu);
}
}
@@ -2495,17 +1992,16 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
// Add the button back in
if (_GM(currMenuIsSave)) {
- menu_ButtonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
- (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1],
- (ItemHandlerFunction)button_Handler);
+ menuItemButton::buttonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
+ (CALLBACK)cb_SaveLoad_Slot, menuItemButton::BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1]);
} else {
- menu_ButtonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
- (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1],
+ menuItemButton::buttonAdd(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
+ (CALLBACK)cb_SaveLoad_Slot, menuItemButton::BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1],
(ItemHandlerFunction)load_Handler);
// Remove the thumbnail
if (_GM(saveLoadThumbNail)) {
- _GM(saveLoadThumbNail) = _GM(menuSprites)[SL_EMPTY_THUMB];
+ _GM(saveLoadThumbNail) = _GM(menuSprites)[Burger::GUI::SL_EMPTY_THUMB];
guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, myMenu);
}
}
@@ -2517,10 +2013,10 @@ void cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
// Disable the save/load button
if (_GM(currMenuIsSave)) {
- menu_DisableButton(nullptr, SL_TAG_SAVE, myMenu);
+ menuItemButton::disableButton(nullptr, SL_TAG_SAVE, myMenu);
guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
} else {
- menu_DisableButton(nullptr, SL_TAG_LOAD, myMenu);
+ menuItemButton::disableButton(nullptr, SL_TAG_LOAD, myMenu);
guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
}
@@ -2566,7 +2062,7 @@ void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
// Disable all other buttons
for (i = 1001; i <= 1010; i++) {
if (i != myButton->tag) {
- menu_DisableButton(nullptr, i, myMenu);
+ menuItemButton::disableButton(nullptr, i, myMenu);
guiMenu::itemRefresh(nullptr, i, myMenu);
}
}
@@ -2598,10 +2094,10 @@ void cb_SaveLoad_Slot(menuItemButton *myButton, guiMenu *myMenu) {
// Enable the save/load button
if (_GM(currMenuIsSave)) {
- menu_EnableButton(nullptr, SL_TAG_SAVE, myMenu);
+ menuItemButton::enableButton(nullptr, SL_TAG_SAVE, myMenu);
guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
} else {
- menu_EnableButton(nullptr, SL_TAG_LOAD, myMenu);
+ menuItemButton::enableButton(nullptr, SL_TAG_LOAD, myMenu);
guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
}
}
@@ -2628,7 +2124,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
bool handled;
// Handle the event just like any other button
- handled = button_Handler(myItem, eventType, event, x, y, currItem);
+ handled = menuItemButton::handler(myItem, eventType, event, x, y, currItem);
// If we've selected a slot, we want the thumbNail to remain on the menu permanently
if (_GM(slotSelected) >= 0) {
@@ -2644,7 +2140,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
return handled;
// This determines that we are over the button
- if ((myItem->itemFlags == BTN_STATE_OVER) || (myItem->itemFlags == BTN_STATE_PRESS)) {
+ if ((myItem->itemFlags == menuItemButton::BTN_STATE_OVER) || (myItem->itemFlags == menuItemButton::BTN_STATE_PRESS)) {
// See if the current _GM(saveLoadThumbNail) is pointing to the correct sprite
if (_GM(saveLoadThumbNail) != _GM(thumbNails)[myItem->specialTag - 1]) {
_GM(saveLoadThumbNail) = _GM(thumbNails)[myItem->specialTag - 1];
@@ -2657,7 +2153,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
// If the mouse has moved outside of the entire range of all 10 buttons,
//or it is over a button which is not hilited it is to be removed.
- if (menu_CursorInsideItem(myItem, x, y)
+ if (menuItem::cursorInsideItem(myItem, x, y)
|| (x < SL_SCROLL_FIELD_X)
|| (x > SL_SCROLL_FIELD_X + SL_SCROLL_FIELD_W)
|| (y < SL_SCROLL_FIELD_Y)
@@ -2665,7 +2161,7 @@ bool load_Handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x,
// Remove the thumbnail
if (_GM(saveLoadThumbNail)) {
- _GM(saveLoadThumbNail) = _GM(menuSprites)[SL_EMPTY_THUMB];
+ _GM(saveLoadThumbNail) = _GM(menuSprites)[Burger::GUI::SL_EMPTY_THUMB];
guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, (guiMenu *)myItem->myMenu);
}
}
@@ -2722,7 +2218,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
CompactMem();
// Load in the game menu sprites
- if (!guiMenu::loadSprites("slmenu", SL_TOTAL_SPRITES)) {
+ if (!guiMenu::loadSprites("slmenu", Burger::GUI::SL_TOTAL_SPRITES)) {
return;
}
@@ -2733,7 +2229,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
_GM(thumbIndex) = 100;
_GM(currMenuIsSave) = saveMenu;
- _GM(slMenu) = guiMenu::create(_GM(menuSprites)[SL_DIALOG_BOX], SAVE_LOAD_MENU_X, SAVE_LOAD_MENU_Y,
+ _GM(slMenu) = guiMenu::create(_GM(menuSprites)[Burger::GUI::SL_DIALOG_BOX], SAVE_LOAD_MENU_X, SAVE_LOAD_MENU_Y,
MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
if (!_GM(slMenu)) {
return;
@@ -2741,16 +2237,16 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
if (_GM(currMenuIsSave)) {
menu_MsgAdd(_GM(slMenu), SL_TAG_SAVE_LABEL, SL_SAVE_LABEL_X, SL_SAVE_LABEL_Y, SL_SAVE_LABEL_W, SL_SAVE_LABEL_H);
- menu_ButtonAdd(_GM(slMenu), SL_TAG_SAVE, SL_SAVE_X, SL_SAVE_Y, SL_SAVE_W, SL_SAVE_H,
- (CALLBACK)cb_SaveLoad_Save, BTN_TYPE_SL_SAVE, true);
+ menuItemButton::buttonAdd(_GM(slMenu), SL_TAG_SAVE, SL_SAVE_X, SL_SAVE_Y, SL_SAVE_W, SL_SAVE_H,
+ (CALLBACK)cb_SaveLoad_Save, menuItemButton::BTN_TYPE_SL_SAVE, true);
} else {
menu_MsgAdd(_GM(slMenu), SL_TAG_LOAD_LABEL, SL_LOAD_LABEL_X, SL_LOAD_LABEL_Y, SL_LOAD_LABEL_W, SL_LOAD_LABEL_H);
- menu_ButtonAdd(_GM(slMenu), SL_TAG_LOAD, SL_LOAD_X, SL_LOAD_Y, SL_LOAD_W, SL_LOAD_H,
- (CALLBACK)cb_SaveLoad_Load, BTN_TYPE_SL_LOAD, true);
+ menuItemButton::buttonAdd(_GM(slMenu), SL_TAG_LOAD, SL_LOAD_X, SL_LOAD_Y, SL_LOAD_W, SL_LOAD_H,
+ (CALLBACK)cb_SaveLoad_Load, menuItemButton::BTN_TYPE_SL_LOAD, true);
}
- menu_ButtonAdd(_GM(slMenu), SL_TAG_CANCEL, SL_CANCEL_X, SL_CANCEL_Y, SL_CANCEL_W, SL_CANCEL_H,
- (CALLBACK)cb_SaveLoad_Cancel, BTN_TYPE_SL_CANCEL);
+ menuItemButton::buttonAdd(_GM(slMenu), SL_TAG_CANCEL, SL_CANCEL_X, SL_CANCEL_Y, SL_CANCEL_W, SL_CANCEL_H,
+ (CALLBACK)cb_SaveLoad_Cancel, menuItemButton::BTN_TYPE_SL_CANCEL);
menu_VSliderAdd(_GM(slMenu), SL_TAG_VSLIDER, SL_SLIDER_X, SL_SLIDER_Y, SL_SLIDER_W, SL_SLIDER_H,
0, (CALLBACK)cb_SaveLoad_VSlider);
@@ -2759,17 +2255,17 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
if (_GM(currMenuIsSave)) {
buttonGreyed = false;
- i_handler = (ItemHandlerFunction)button_Handler;
+ i_handler = (ItemHandlerFunction)menuItemButton::handler;
} else {
buttonGreyed = true;
i_handler = (ItemHandlerFunction)load_Handler;
}
for (int32 i = 0; i < MAX_SLOTS_SHOWN; i++) {
- menu_ButtonAdd(_GM(slMenu), 1001 + i,
+ menuItemButton::buttonAdd(_GM(slMenu), 1001 + i,
SL_SCROLL_FIELD_X, SL_SCROLL_FIELD_Y + i * SL_SCROLL_LINE_H,
SL_SCROLL_LINE_W, SL_SCROLL_LINE_H,
- (CALLBACK)cb_SaveLoad_Slot, BTN_TYPE_SL_TEXT,
+ (CALLBACK)cb_SaveLoad_Slot, menuItemButton::BTN_TYPE_SL_TEXT,
buttonGreyed && (!_GM(slotInUse)[i]), true, _GM(slotTitles)[i], i_handler);
}
@@ -2782,7 +2278,7 @@ void CreateSaveLoadMenu(RGB8 *myPalette, bool saveMenu) {
} else {
UpdateThumbNails(0, _GM(slMenu));
- _GM(saveLoadThumbNail) = _GM(menuSprites)[SL_EMPTY_THUMB];
+ _GM(saveLoadThumbNail) = _GM(menuSprites)[Burger::GUI::SL_EMPTY_THUMB];
}
menu_MsgAdd(_GM(slMenu), SL_TAG_THUMBNAIL, SL_THUMBNAIL_X, SL_THUMBNAIL_Y, SL_THUMBNAIL_W, SL_THUMBNAIL_H, false);
diff --git a/engines/m4/burger/gui/game_menu.h b/engines/m4/burger/gui/game_menu.h
index ad365960f74..7a8ae6df6f6 100644
--- a/engines/m4/burger/gui/game_menu.h
+++ b/engines/m4/burger/gui/game_menu.h
@@ -50,14 +50,6 @@ extern menuItemMsg *menu_MsgAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, in
extern void menu_DisableMsg(menuItemMsg *myItem, int32 tag, guiMenu *myMenu);
extern void menu_EnableMsg(menuItemMsg *myItem, int32 tag, guiMenu *myMenu);
-// Buttons
-bool button_Handler(menuItemButton *theItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem);
-menuItemButton *menu_ButtonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback = nullptr,
- int32 buttonType = 0, bool ghosted = false, bool transparent = false,
- const char *prompt = nullptr, ItemHandlerFunction i_handler = (ItemHandlerFunction)button_Handler);
-void menu_DisableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
-void menu_EnableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
-
// Horizontal sliders
menuItemHSlider *menu_HSliderAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h,
int32 initPercent = 0, CALLBACK callback = nullptr, bool transparent = false);
@@ -83,43 +75,6 @@ extern void CreateF3LoadMenu(RGB8 *myPalette);
void CreateLoadMenuFromMain(RGB8 *myPalette);
void CreateGameMenuFromMain(RGB8 *myPalette);
-
-//======================================
-//
-// gamemenu module defines
-//
-
-// 128 very light green
-// 129 light green
-// 130 medium green
-// 131 dark green
-// 133 light red
-// 136 red
-// 142 dark red
-// 186 purple
-// 206 dark grey
-// 236 very dark purple
-
-#define TEXT_COLOR_GREY_HILITE 192
-#define TEXT_COLOR_GREY_FOREGROUND 210
-#define TEXT_COLOR_GREY_SHADOW 229
-
-#define TEXT_COLOR_NORM_HILITE 3
-#define TEXT_COLOR_NORM_FOREGROUND 2
-#define TEXT_COLOR_NORM_SHADOW 1
-
-#define TEXT_COLOR_OVER_HILITE 3
-#define TEXT_COLOR_OVER_FOREGROUND 2
-#define TEXT_COLOR_OVER_SHADOW 1
-
-#define TEXT_COLOR_PRESS_HILITE 3
-#define TEXT_COLOR_PRESS_FOREGROUND 2
-#define TEXT_COLOR_PRESS_SHADOW 1
-
-#define SLIDER_BAR_COLOR 129
-
-
-
//======================================
//
// Game menu enums and defines
@@ -143,51 +98,6 @@ enum game_menu_button_tags {
#define SAVE_LOAD_MENU_W 344
#define SAVE_LOAD_MENU_H 460
-enum save_load_menu_sprites {
-
- SL_DIALOG_BOX,
- SL_EMPTY_THUMB,
-
- SL_SAVE_BTN_GREY,
- SL_SAVE_BTN_NORM,
- SL_SAVE_BTN_OVER,
- SL_SAVE_BTN_PRESS,
-
- SL_LOAD_BTN_GREY,
- SL_LOAD_BTN_NORM,
- SL_LOAD_BTN_OVER,
- SL_LOAD_BTN_PRESS,
-
- SL_CANCEL_BTN_NORM,
- SL_CANCEL_BTN_OVER,
- SL_CANCEL_BTN_PRESS,
-
- SL_UP_BTN_GREY,
- SL_UP_BTN_NORM,
- SL_UP_BTN_OVER,
- SL_UP_BTN_PRESS,
-
- SL_DOWN_BTN_GREY,
- SL_DOWN_BTN_NORM,
- SL_DOWN_BTN_OVER,
- SL_DOWN_BTN_PRESS,
-
- SL_SAVE_LABEL,
- SL_LOAD_LABEL,
-
- SL_SLIDER_BTN_NORM,
- SL_SLIDER_BTN_OVER,
- SL_SLIDER_BTN_PRESS,
-
- SL_LINE_NORM,
- SL_LINE_OVER,
- SL_LINE_PRESS,
-
- SL_SCROLL_BAR,
-
- SL_TOTAL_SPRITES
-};
-
enum save_load_menu_item_tags {
SL_TAG_SAVE = 100,
SL_TAG_SAVE_LABEL,
@@ -252,29 +162,8 @@ enum save_load_menu_item_tags {
#define SL_THUMBNAIL_H 162
/**
- * Options menu enums and defines
+ * Options menu defines
*/
-enum options_menu_sprites {
-
- OM_DIALOG_BOX,
-
- OM_SLIDER_BTN_NORM,
- OM_SLIDER_BTN_OVER,
- OM_SLIDER_BTN_PRESS,
-
- OM_SLIDER_BAR,
-
- OM_DONE_BTN_GREY,
- OM_DONE_BTN_NORM,
- OM_DONE_BTN_OVER,
- OM_DONE_BTN_PRESS,
-
- OM_CANCEL_BTN_NORM,
- OM_CANCEL_BTN_OVER,
- OM_CANCEL_BTN_PRESS,
-
- OM_TOTAL_SPRITES
-};
#define OPTIONS_MENU_X 175
#define OPTIONS_MENU_Y 100
diff --git a/engines/m4/gui/gui_menu.cpp b/engines/m4/gui/gui_menu.cpp
index a4a32ac12ec..7ae72e61400 100644
--- a/engines/m4/gui/gui_menu.cpp
+++ b/engines/m4/gui/gui_menu.cpp
@@ -42,6 +42,42 @@
namespace M4 {
namespace GUI {
+void gui_DrawSprite(Sprite *mySprite, Buffer *myBuff, int32 x, int32 y) {
+ DrawRequest spriteDrawReq;
+ Buffer drawSpriteBuff;
+
+ if ((!mySprite) || (!myBuff)) {
+ return;
+ }
+
+ if (mySprite->sourceHandle) {
+ HLock(mySprite->sourceHandle);
+ mySprite->data = (uint8 *)((intptr) * (mySprite->sourceHandle) + mySprite->sourceOffset);
+
+ drawSpriteBuff.w = mySprite->w;
+ drawSpriteBuff.stride = mySprite->w;
+ drawSpriteBuff.h = mySprite->h;
+ drawSpriteBuff.encoding = (mySprite->encoding) & (uint8)0x7f;
+ drawSpriteBuff.data = mySprite->data;
+
+ spriteDrawReq.Src = &drawSpriteBuff;
+ spriteDrawReq.Dest = myBuff;
+ spriteDrawReq.x = x;
+ spriteDrawReq.y = y;
+ spriteDrawReq.scaleX = 100;
+ spriteDrawReq.scaleY = 100;
+ spriteDrawReq.srcDepth = 0;
+ spriteDrawReq.depthCode = nullptr;
+ spriteDrawReq.Pal = nullptr;
+ spriteDrawReq.ICT = nullptr;
+
+ gr_sprite_draw(&spriteDrawReq);
+
+ // Unlock the handle
+ HUnLock(mySprite->sourceHandle);
+ }
+}
+
bool guiMenu::initialize(RGB8 *myPalette) {
int32 i, memAvail;
@@ -599,9 +635,6 @@ void guiMenu::itemRefresh(menuItem *myItem, int32 tag, guiMenu *myMenu) {
}
}
-
-//----------------------------- GAME MENU FUNCTIONS ---------------------------------//
-
bool guiMenu::loadSprites(const char *series, int32 numSprites) {
int32 i;
@@ -661,5 +694,443 @@ void guiMenu::unloadSprites() {
_GM(spriteCount) = 0;
}
+//----------------------------- GENERAL ITEM FUNCTIONS ---------------------------------//
+
+void menuItem::destroyItem(menuItem *theItem) {
+ // Verify params
+ if (!theItem) {
+ return;
+ }
+ if (theItem->background) {
+ delete theItem->background;
+ }
+
+ delete theItem;
+}
+
+bool menuItem::cursorInsideItem(menuItem *myItem, int32 cursorX, int32 cursorY) {
+ if ((cursorX >= myItem->x1) && (cursorX <= myItem->x2) && (cursorY >= myItem->y1) && (cursorY <= myItem->y2)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+//----------------------------- BUTTON FUNCTIONS ---------------------------------//
+
+void menuItemButton::drawButton(menuItemButton *myItem, guiMenu *myMenu, int32 x, int32 y, int32, int32) {
+ Buffer *myBuff = nullptr;
+ Buffer *backgroundBuff = nullptr;
+ Sprite *mySprite = nullptr;
+ char tempStr[32];
+
+ // Verify params
+ if (!myItem || !myMenu) {
+ return;
+ }
+
+ // If the item is marked transparent, get the background buffer
+ if (myItem->transparent) {
+ if (!myItem->background) {
+ return;
+ }
+ backgroundBuff = myItem->background->get_buffer();
+ if (!backgroundBuff) {
+ return;
+ }
+ }
+
+ // Select the sprite
+ switch (myItem->buttonType) {
+ case BTN_TYPE_GM_GENERIC:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[GM_BUTTON_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[GM_BUTTON_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[GM_BUTTON_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[GM_BUTTON_GREY];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_SL_SAVE:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_SAVE_BTN_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_SAVE_BTN_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_SAVE_BTN_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_SAVE_BTN_GREY];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_SL_LOAD:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LOAD_BTN_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LOAD_BTN_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LOAD_BTN_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LOAD_BTN_GREY];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_SL_TEXT:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_OVER:
+ font_set_colors(TEXT_COLOR_OVER_SHADOW, TEXT_COLOR_OVER_FOREGROUND, TEXT_COLOR_OVER_HILITE);
+ // Gr_font_set_color(TEXT_COLOR_OVER);
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ font_set_colors(TEXT_COLOR_PRESS_SHADOW, TEXT_COLOR_PRESS_FOREGROUND, TEXT_COLOR_PRESS_HILITE);
+ // Gr_font_set_color(TEXT_COLOR_PRESS);
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_PRESS];
+ break;
+ case BTN_STATE_GREY:
+ font_set_colors(TEXT_COLOR_GREY_SHADOW, TEXT_COLOR_GREY_FOREGROUND, TEXT_COLOR_GREY_HILITE);
+ // Gr_font_set_color(TEXT_COLOR_GREY);
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_NORM];
+ break;
+ default:
+ case BTN_STATE_NORM:
+ font_set_colors(TEXT_COLOR_NORM_SHADOW, TEXT_COLOR_NORM_FOREGROUND, TEXT_COLOR_NORM_HILITE);
+ // Gr_font_set_color(TEXT_COLOR_NORM);
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_LINE_NORM];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_SL_CANCEL:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_CANCEL_BTN_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_CANCEL_BTN_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_CANCEL_BTN_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[Burger::GUI::SL_CANCEL_BTN_NORM];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_OM_DONE:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_DONE_BTN_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_DONE_BTN_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_DONE_BTN_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_DONE_BTN_GREY];
+ break;
+ }
+ break;
+
+ case BTN_TYPE_OM_CANCEL:
+ switch (myItem->itemFlags) {
+ case BTN_STATE_NORM:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_CANCEL_BTN_NORM];
+ break;
+ case BTN_STATE_OVER:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_CANCEL_BTN_OVER];
+ break;
+ case BTN_STATE_PRESS:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_CANCEL_BTN_PRESS];
+ break;
+ default:
+ case BTN_STATE_GREY:
+ mySprite = _GM(menuSprites)[Burger::GUI::OM_CANCEL_BTN_NORM];
+ break;
+ }
+ break;
+ }
+
+ // Get the menu buffer
+ myBuff = myMenu->menuBuffer->get_buffer();
+ if (!myBuff) {
+ return;
+ }
+
+ // If the item is tagged as transparent, we need to fill in it's background behind it
+ if (backgroundBuff) {
+ gr_buffer_rect_copy_2(backgroundBuff, myBuff, 0, 0, x, y, backgroundBuff->w, backgroundBuff->h);
+ myItem->background->release();
+ }
+
+ // Draw the button sprite in
+ gui_DrawSprite(mySprite, myBuff, x, y);
+
+ // If the button is a textbutton, write in the text
+ if ((myItem->buttonType == BTN_TYPE_SL_TEXT) && (myItem->prompt)) {
+ // Write in the special tag
+ Common::sprintf_s(tempStr, 32, "%02d", myItem->tag - 1000 + _GM(firstSlotIndex));
+
+ gr_font_set(_GM(menuFont));
+ gr_font_write(myBuff, tempStr, x + 4, y + 1, 0, -1);
+ gr_font_write(myBuff, myItem->prompt, x + 26, y + 1, 0, -1);
+ }
+
+ // Release the menu buffer
+ myMenu->menuBuffer->release();
+}
+
+bool menuItemButton::handler(menuItemButton *myItem, int32 eventType, int32 event, int32 x, int32 y, void **currItem) {
+ bool redrawItem, execCallback, handled;
+ ScreenContext *myScreen;
+ int32 status;
+ int32 currTag;
+ guiMenu *currMenu;
+ menuItem *tempItem;
+
+ // Verify params
+ if (!myItem) {
+ return false;
+ }
+
+ if (!(eventType == EVENT_MOUSE)) {
+ return false;
+ }
+
+ if (myItem->itemFlags == BTN_STATE_GREY) {
+ return false;
+ }
+
+ redrawItem = false;
+ execCallback = false;
+ handled = true;
+
+ switch (event) {
+ case _ME_L_click:
+ case _ME_doubleclick:
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
+ myItem->itemFlags = BTN_STATE_PRESS;
+ *currItem = myItem;
+ redrawItem = true;
+ } else {
+ *currItem = nullptr;
+ if (myItem->itemFlags != BTN_STATE_NORM) {
+ myItem->itemFlags = BTN_STATE_NORM;
+ redrawItem = true;
+ }
+ }
+ break;
+
+ case _ME_L_drag:
+ case _ME_doubleclick_drag:
+ if (!*currItem) {
+ return true;
+ }
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
+ if (myItem->itemFlags != BTN_STATE_PRESS) {
+ myItem->itemFlags = BTN_STATE_PRESS;
+ redrawItem = true;
+ }
+ } else {
+ if (myItem->itemFlags != BTN_STATE_OVER) {
+ myItem->itemFlags = BTN_STATE_OVER;
+ redrawItem = true;
+ }
+ }
+ break;
+
+ case _ME_L_release:
+ case _ME_doubleclick_release:
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
+ if (*currItem) {
+ execCallback = true;
+ } else {
+ *currItem = myItem;
+ }
+ myItem->itemFlags = BTN_STATE_OVER;
+ redrawItem = true;
+ } else {
+ *currItem = nullptr;
+ myItem->itemFlags = BTN_STATE_NORM;
+ redrawItem = true;
+ handled = false;
+ }
+ break;
+
+ case _ME_move:
+ if (menuItem::cursorInsideItem(myItem, x, y)) {
+ *currItem = myItem;
+ if (myItem->itemFlags != BTN_STATE_OVER) {
+ myItem->itemFlags = BTN_STATE_OVER;
+ redrawItem = true;
+ }
+ } else {
+ *currItem = nullptr;
+ if (myItem->itemFlags != BTN_STATE_NORM) {
+ myItem->itemFlags = BTN_STATE_NORM;
+ redrawItem = true;
+ handled = false;
+ }
+ }
+ break;
+
+ case _ME_L_hold:
+ case _ME_doubleclick_hold:
+ break;
+ }
+
+ // See if we need to redraw the button
+ if (redrawItem) {
+ (myItem->redraw)(myItem, myItem->myMenu, myItem->x1, myItem->y1, 0, 0);
+ myScreen = vmng_screen_find(myItem->myMenu, &status);
+ if (myScreen && (status == SCRN_ACTIVE)) {
+ RestoreScreens(myScreen->x1 + myItem->x1, myScreen->y1 + myItem->y1,
+ myScreen->x1 + myItem->x2, myScreen->y1 + myItem->y2);
+ }
+ }
+
+ // See if we need to call the callback function
+ if (execCallback && myItem->callback) {
+ // digi_play(inv_click_snd, 2, 255, -1, inv_click_snd_room_lock);
+ currMenu = myItem->myMenu;
+ currTag = myItem->tag;
+ _GM(buttonClosesDialog) = false;
+
+ (myItem->callback)(myItem, myItem->myMenu);
+
+ status = 0;
+ myScreen = _GM(buttonClosesDialog) ? nullptr : vmng_screen_find(myItem->myMenu, &status);
+
+ if ((!myScreen) || (status != SCRN_ACTIVE)) {
+ *currItem = nullptr;
+ } else {
+ tempItem = guiMenu::getItem(currTag, currMenu);
+ if (!tempItem) {
+ *currItem = nullptr;
+ }
+ }
+ }
+
+ return handled;
+}
+
+menuItemButton *menuItemButton::buttonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback, int32 buttonType,
+ bool greyed, bool transparent, const char *prompt, ItemHandlerFunction i_handler) {
+ menuItemButton *newItem;
+ ScreenContext *myScreen;
+ int32 status;
+
+ // Verify params
+ if (!myMenu) {
+ return nullptr;
+ }
+
+ // Allocate a new one
+ newItem = new menuItemButton();
+
+ // Initialize the struct
+ newItem->next = myMenu->itemList;
+ newItem->prev = nullptr;
+ if (myMenu->itemList) {
+ myMenu->itemList->prev = newItem;
+ }
+ myMenu->itemList = newItem;
+
+ newItem->myMenu = myMenu;
+ newItem->tag = tag;
+ newItem->x1 = x;
+ newItem->y1 = y;
+ newItem->x2 = x + w - 1;
+ newItem->y2 = y + h - 1;
+ newItem->callback = callback;
+
+ if (!transparent) {
+ newItem->transparent = false;
+ newItem->background = nullptr;
+ } else {
+ newItem->transparent = true;
+ newItem->background = guiMenu::copyBackground(myMenu, x, y, w, h);
+ }
+
+ if (greyed) {
+ newItem->itemFlags = BTN_STATE_GREY;
+ } else {
+ newItem->itemFlags = BTN_STATE_NORM;
+ }
+ newItem->buttonType = buttonType;
+
+ // Note: prompt is not duplicated, therefore, make sure the name is stored in non-volatile memory
+ newItem->prompt = prompt;
+ newItem->specialTag = tag - 1000;
+
+ newItem->redraw = (DrawFunction)menuItemButton::drawButton;
+ newItem->destroy = (DestroyFunction)menuItem::destroyItem;
+ newItem->itemEventHandler = i_handler;
+
+ // Draw the button in now
+ (newItem->redraw)(newItem, myMenu, x, y, 0, 0);
+
+ // See if the screen is currently visible
+ myScreen = vmng_screen_find(myMenu, &status);
+ if (myScreen && (status == SCRN_ACTIVE)) {
+ RestoreScreens(myScreen->x1 + newItem->x1, myScreen->y1 + newItem->y1,
+ myScreen->x1 + newItem->x2, myScreen->y1 + newItem->y2);
+ }
+
+ return newItem;
+}
+
+void menuItemButton::disableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
+ // Verify params
+ if (!myMenu)
+ return;
+
+ if (!myItem)
+ myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
+ if (!myItem)
+ return;
+
+ myItem->itemFlags = BTN_STATE_GREY;
+}
+
+void menuItemButton::enableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu) {
+ // Verify params
+ if (!myMenu)
+ return;
+
+ if (!myItem)
+ myItem = (menuItemButton *)guiMenu::getItem(tag, myMenu);
+ if (!myItem)
+ return;
+
+ myItem->itemFlags = BTN_STATE_NORM;
+}
+
} // namespace GUI
} // namespace M4
diff --git a/engines/m4/gui/gui_menu.h b/engines/m4/gui/gui_menu.h
index 5172c26132f..9b938eefae8 100644
--- a/engines/m4/gui/gui_menu.h
+++ b/engines/m4/gui/gui_menu.h
@@ -29,6 +29,78 @@
#include "m4/gui/gui_univ.h"
namespace M4 {
+
+namespace Burger {
+namespace GUI {
+
+enum save_load_menu_sprites {
+ SL_DIALOG_BOX,
+ SL_EMPTY_THUMB,
+
+ SL_SAVE_BTN_GREY,
+ SL_SAVE_BTN_NORM,
+ SL_SAVE_BTN_OVER,
+ SL_SAVE_BTN_PRESS,
+
+ SL_LOAD_BTN_GREY,
+ SL_LOAD_BTN_NORM,
+ SL_LOAD_BTN_OVER,
+ SL_LOAD_BTN_PRESS,
+
+ SL_CANCEL_BTN_NORM,
+ SL_CANCEL_BTN_OVER,
+ SL_CANCEL_BTN_PRESS,
+
+ SL_UP_BTN_GREY,
+ SL_UP_BTN_NORM,
+ SL_UP_BTN_OVER,
+ SL_UP_BTN_PRESS,
+
+ SL_DOWN_BTN_GREY,
+ SL_DOWN_BTN_NORM,
+ SL_DOWN_BTN_OVER,
+ SL_DOWN_BTN_PRESS,
+
+ SL_SAVE_LABEL,
+ SL_LOAD_LABEL,
+
+ SL_SLIDER_BTN_NORM,
+ SL_SLIDER_BTN_OVER,
+ SL_SLIDER_BTN_PRESS,
+
+ SL_LINE_NORM,
+ SL_LINE_OVER,
+ SL_LINE_PRESS,
+
+ SL_SCROLL_BAR,
+
+ SL_TOTAL_SPRITES
+};
+
+enum options_menu_sprites {
+ OM_DIALOG_BOX,
+
+ OM_SLIDER_BTN_NORM,
+ OM_SLIDER_BTN_OVER,
+ OM_SLIDER_BTN_PRESS,
+
+ OM_SLIDER_BAR,
+
+ OM_DONE_BTN_GREY,
+ OM_DONE_BTN_NORM,
+ OM_DONE_BTN_OVER,
+ OM_DONE_BTN_PRESS,
+
+ OM_CANCEL_BTN_NORM,
+ OM_CANCEL_BTN_OVER,
+ OM_CANCEL_BTN_PRESS,
+
+ OM_TOTAL_SPRITES
+};
+
+} // namespace GUI
+} // namespace Burger
+
namespace GUI {
#define _GM(X) ::M4::g_vars->_menu.X
@@ -59,64 +131,119 @@ enum game_menu_sprites {
struct guiMenu;
struct menuItem {
- menuItem *next;
- menuItem *prev;
+ enum {
+ TEXT_COLOR_GREY_HILITE = 192,
+ TEXT_COLOR_GREY_FOREGROUND = 210,
+ TEXT_COLOR_GREY_SHADOW = 229,
+
+ TEXT_COLOR_NORM_HILITE = 3,
+ TEXT_COLOR_NORM_FOREGROUND = 2,
+ TEXT_COLOR_NORM_SHADOW = 1,
+
+ TEXT_COLOR_OVER_HILITE = 3,
+ TEXT_COLOR_OVER_FOREGROUND = 2,
+ TEXT_COLOR_OVER_SHADOW = 1,
- guiMenu *myMenu;
- int32 tag;
+ TEXT_COLOR_PRESS_HILITE = 3,
+ TEXT_COLOR_PRESS_FOREGROUND = 2,
+ TEXT_COLOR_PRESS_SHADOW = 1,
- int32 x1, y1, x2, y2;
+ SLIDER_BAR_COLOR = 129
+ };
- bool transparent;
- GrBuff *background;
+ menuItem *next = nullptr;
+ menuItem *prev = nullptr;
- CALLBACK callback;
- DrawFunction redraw;
- DestroyFunction destroy;
- ItemHandlerFunction itemEventHandler;
+ guiMenu *myMenu = nullptr;
+ int32 tag = 0;
+
+ int32 x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+
+ bool transparent = false;
+ GrBuff *background = nullptr;
+
+ CALLBACK callback = nullptr;
+ DrawFunction redraw = nullptr;
+ DestroyFunction destroy = nullptr;
+ ItemHandlerFunction itemEventHandler = nullptr;
+
+ static void destroyItem(menuItem *theItem);
+ static bool cursorInsideItem(menuItem *myItem, int32 cursorX, int32 cursorY);
};
struct menuItemMsg : public menuItem {
- int32 itemFlags;
+ int32 itemFlags = 0;
};
struct menuItemButton : public menuItem {
- int32 itemFlags;
- int32 buttonType;
- const char *prompt;
- menuItem *assocItem;
- int32 specialTag;
+private:
+ static void drawButton(menuItemButton *myItem, guiMenu *myMenu,
+ int32 x, int32 y, int32, int32);
+
+public:
+ enum button_states {
+ BTN_STATE_NORM = 0,
+ BTN_STATE_OVER = 1,
+ BTN_STATE_PRESS = 2,
+ BTN_STATE_GREY = 3
+ };
+
+ enum button_types {
+ BTN_TYPE_GM_GENERIC,
+ BTN_TYPE_SL_SAVE,
+ BTN_TYPE_SL_LOAD,
+ BTN_TYPE_SL_CANCEL,
+ BTN_TYPE_SL_TEXT,
+ BTN_TYPE_OM_DONE,
+ BTN_TYPE_OM_CANCEL,
+
+ BTN_TYPE_TOTAL_NUMBER
+ };
+
+ int32 itemFlags = 0;
+ int32 buttonType = 0;
+ const char *prompt = nullptr;
+ menuItem *assocItem = nullptr;
+ int32 specialTag = 0;
+
+ static menuItemButton *buttonAdd(guiMenu *myMenu, int32 tag, int32 x, int32 y, int32 w, int32 h, CALLBACK callback = nullptr,
+ int32 buttonType = 0, bool ghosted = false, bool transparent = false,
+ const char *prompt = nullptr, ItemHandlerFunction i_handler = (ItemHandlerFunction)handler);
+ static void disableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
+ static void enableButton(menuItemButton *myItem, int32 tag, guiMenu *myMenu);
+ static bool handler(menuItemButton *theItem, int32 eventType, int32 event,
+ int32 x, int32 y, void **currItem);
};
struct menuItemHSlider : public menuItem {
- int32 itemFlags;
+ int32 itemFlags = 0;
- int32 thumbW, thumbH;
- int32 thumbX, maxThumbX;
+ int32 thumbW = 0, thumbH = 0;
+ int32 thumbX = 0, maxThumbX = 0;
- int32 percent;
+ int32 percent = 0;
};
struct menuItemVSlider : public menuItem {
- int32 itemFlags;
+ int32 itemFlags = 0;
- int32 thumbW, thumbH;
- int32 thumbY, minThumbY, maxThumbY;
+ int32 thumbW = 0, thumbH = 0;
+ int32 thumbY = 0, minThumbY = 0, maxThumbY = 0;
- int32 percent;
+ int32 percent = 0;
};
struct menuItemTextField : public menuItem {
- int32 itemFlags;
+ int32 itemFlags = 0;
- int32 specialTag;
- int32 pixWidth;
+ int32 specialTag = 0;
+ int32 pixWidth = 0;
- char prompt[80];
- char *promptEnd;
+ char prompt[80] = { 0 };
+ char *promptEnd = nullptr;
- char *cursor;
+ char *cursor = nullptr;
};
struct guiMenu {
@@ -125,11 +252,11 @@ private:
static bool eventHandler(guiMenu *theMenu, int32 eventType, int32 parm1, int32 parm2, int32 parm3, bool *currScreen);
public:
- GrBuff *menuBuffer;
- menuItem *itemList;
- CALLBACK cb_return;
- CALLBACK cb_esc;
- EventHandler menuEventHandler;
+ GrBuff *menuBuffer = nullptr;
+ menuItem *itemList = nullptr;
+ CALLBACK cb_return = nullptr;
+ CALLBACK cb_esc = nullptr;
+ EventHandler menuEventHandler = nullptr;
static bool initialize(RGB8 *myPalette);
static void shutdown(bool fadeToColor);
@@ -148,6 +275,7 @@ public:
struct MenuGlobals {
//GLOBAL VARS
bool menuSystemInitialized = false;
+ bool buttonClosesDialog = false;
bool interfaceWasVisible = false;
RGB8 *menuPalette = nullptr;
bool dumpedCodes = false;
@@ -198,6 +326,8 @@ struct MenuGlobals {
}
};
+extern void gui_DrawSprite(Sprite *mySprite, Buffer *myBuff, int32 x, int32 y);
+
//======================================
//
// gamemenu module defines
diff --git a/engines/m4/riddle/gui/game_menu.cpp b/engines/m4/riddle/gui/game_menu.cpp
index 966e4f95b12..0d12b667564 100644
--- a/engines/m4/riddle/gui/game_menu.cpp
+++ b/engines/m4/riddle/gui/game_menu.cpp
@@ -80,26 +80,26 @@ void GameMenu::show(RGB8 *myPalette) {
GAME_MENU_X, GAME_MENU_Y, MENU_DEPTH | SF_GET_ALL | SF_BLOCK_ALL | SF_IMMOVABLE);
assert(_GM(gameMenu));
- Burger::GUI::menu_ButtonAdd(_GM(gameMenu), GM_TAG_QUIT,
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_QUIT,
GM_QUIT_X, GM_QUIT_Y, GM_QUIT_W, GM_QUIT_H, cbQuitGame);
- Burger::GUI::menu_ButtonAdd(_GM(gameMenu), GM_TAG_MAIN,
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_MAIN,
GM_MAIN_X, GM_MAIN_Y, GM_MAIN_W, GM_MAIN_H, cbMainMenu);
#if 0
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cb_Game_Options);
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cb_Game_Resume);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cb_Game_Options);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cb_Game_Resume);
if (!_GM(gameMenuFromMain)) {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save);
} else {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save, BTN_TYPE_GM_GENERIC, true);
}
// See if there are any games to load
if (g_engine->savesExist()) {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load);
} else {
- menu_ButtonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load, BTN_TYPE_GM_GENERIC, true);
}
#endif
// Configure the game so pressing <esc> will cause the menu to disappear and the game to resume
Commit: de88b06b3adc7cead6cd6136c4c2da74ad904bf2
https://github.com/scummvm/scummvm/commit/de88b06b3adc7cead6cd6136c4c2da74ad904bf2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-12T21:35:31-08:00
Commit Message:
M4: RIDDLE: Add remaining buttons to Game Menu
Changed paths:
engines/m4/riddle/gui/game_menu.cpp
engines/m4/riddle/gui/game_menu.h
diff --git a/engines/m4/riddle/gui/game_menu.cpp b/engines/m4/riddle/gui/game_menu.cpp
index 0d12b667564..338dd927afe 100644
--- a/engines/m4/riddle/gui/game_menu.cpp
+++ b/engines/m4/riddle/gui/game_menu.cpp
@@ -62,6 +62,30 @@ namespace GUI {
#define GM_MAIN_W 26
#define GM_MAIN_H 26
+#define GM_TAG_OPTIONS 3
+#define GM_OPTIONS_X 162
+#define GM_OPTIONS_Y 31
+#define GM_OPTIONS_W 26
+#define GM_OPTIONS_H 26
+
+#define GM_TAG_RESUME 4
+#define GM_RESUME_X 54
+#define GM_RESUME_Y 94
+#define GM_RESUME_W 26
+#define GM_RESUME_H 26
+
+#define GM_TAG_SAVE 5
+#define GM_SAVE_X 108
+#define GM_SAVE_Y 94
+#define GM_SAVE_W 26
+#define GM_SAVE_H 26
+
+#define GM_TAG_LOAD 6
+#define GM_LOAD_X 162
+#define GM_LOAD_Y 94
+#define GM_LOAD_W 26
+#define GM_LOAD_H 26
+
void GameMenu::show(RGB8 *myPalette) {
if (!_G(menuSystemInitialized)) {
guiMenu::initialize(myPalette);
@@ -84,24 +108,22 @@ void GameMenu::show(RGB8 *myPalette) {
GM_QUIT_X, GM_QUIT_Y, GM_QUIT_W, GM_QUIT_H, cbQuitGame);
menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_MAIN,
GM_MAIN_X, GM_MAIN_Y, GM_MAIN_W, GM_MAIN_H, cbMainMenu);
-
- #if 0
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cb_Game_Options);
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cb_Game_Resume);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_OPTIONS, GM_OPTIONS_X, GM_OPTIONS_Y, GM_OPTIONS_W, GM_OPTIONS_H, cbOptions);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_RESUME, GM_RESUME_X, GM_RESUME_Y, GM_RESUME_W, GM_RESUME_H, cbResume);
if (!_GM(gameMenuFromMain)) {
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cbSave);
} else {
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cb_Game_Save, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_SAVE, GM_SAVE_X, GM_SAVE_Y, GM_SAVE_W, GM_SAVE_H, cbSave, menuItemButton::BTN_TYPE_GM_GENERIC, true);
}
// See if there are any games to load
if (g_engine->savesExist()) {
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cbLoad);
} else {
- menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cb_Game_Load, BTN_TYPE_GM_GENERIC, true);
+ menuItemButton::buttonAdd(_GM(gameMenu), GM_TAG_LOAD, GM_LOAD_X, GM_LOAD_Y, GM_LOAD_W, GM_LOAD_H, cbLoad, menuItemButton::BTN_TYPE_GM_GENERIC, true);
}
-#endif
+
// Configure the game so pressing <esc> will cause the menu to disappear and the game to resume
guiMenu::configure(_GM(gameMenu), cbResume, cbResume);
@@ -166,6 +188,18 @@ void GameMenu::cbResume(void *, void *) {
guiMenu::shutdown(true);
}
+void GameMenu::cbOptions(void *, void *) {
+ // TODO
+}
+
+void GameMenu::cbSave(void *, void *) {
+ // TODO
+}
+
+void GameMenu::cbLoad(void *, void *) {
+ // TODO
+}
+
/*-------------------- ACCESS METHODS --------------------*/
void CreateGameMenu(RGB8 *myPalette) {
diff --git a/engines/m4/riddle/gui/game_menu.h b/engines/m4/riddle/gui/game_menu.h
index 4170cd9b862..ef6a8c2faaf 100644
--- a/engines/m4/riddle/gui/game_menu.h
+++ b/engines/m4/riddle/gui/game_menu.h
@@ -35,6 +35,9 @@ private:
static void cbQuitGame(void *, void *);
static void cbMainMenu(void *, void *);
static void cbResume(void *, void *);
+ static void cbOptions(void *, void *);
+ static void cbSave(void *, void *);
+ static void cbLoad(void *, void *);
public:
static void show(RGB8 *myPalette);
More information about the Scummvm-git-logs
mailing list