[Scummvm-git-logs] scummvm master -> 1f6c6ccc48ce86e502de43b504837c391d1338f2

dreammaster noreply at scummvm.org
Sat Feb 15 17:06:44 UTC 2025


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
7c84a61fcc M4: RIDDLE: Remainder of save dialog methods, error menu
1f6c6ccc48 M4: BURGER: Wrap game menus in their own classes


Commit: 7c84a61fcc274d941d051c2b6f567483d29e3bac
    https://github.com/scummvm/scummvm/commit/7c84a61fcc274d941d051c2b6f567483d29e3bac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-15T09:06:35-08:00

Commit Message:
M4: RIDDLE: Remainder of save dialog methods, error menu

Changed paths:
    engines/m4/burger/gui/game_menu.cpp
    engines/m4/burger/gui/game_menu.h
    engines/m4/riddle/gui/game_menu.cpp
    engines/m4/riddle/gui/game_menu.h


diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index 8c9f43b7ece..6f348fbe21c 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -353,6 +353,30 @@ void CreateOptionsMenu(RGB8 *myPalette) {
 //--------------------------------   ERR MENU   --------------------------------------//
 //------------------------------------------------------------------------------------//
 
+enum error_menu_sprites {
+	EM_DIALOG_BOX,
+
+	EM_RETURN_BTN_NORM,
+	EM_RETURN_BTN_OVER,
+	EM_RETURN_BTN_PRESS,
+
+	EM_TOTAL_SPRITES
+};
+
+enum error_menu_tags {
+	EM_TAG_RETURN = 1
+};
+
+#define ERROR_MENU_X	 100
+#define ERROR_MENU_Y	 100
+#define ERROR_MENU_W	 100
+#define ERROR_MENU_H	 100
+
+#define EM_RETURN_X	  15
+#define EM_RETURN_Y	  15
+#define EM_RETURN_W	  15
+#define EM_RETURN_H	  15
+
 void DestroyErrMenu();
 
 void cb_Err_Done(void *, void *) {
diff --git a/engines/m4/burger/gui/game_menu.h b/engines/m4/burger/gui/game_menu.h
index be5b781a56a..6953c3b27b2 100644
--- a/engines/m4/burger/gui/game_menu.h
+++ b/engines/m4/burger/gui/game_menu.h
@@ -84,33 +84,6 @@ enum game_menu_button_tags {
 	GM_TAG_MAIN = 6
 };
 
-/**
- * Error menu enums and defines
- */
-enum error_menu_sprites {
-	EM_DIALOG_BOX,
-
-	EM_RETURN_BTN_NORM,
-	EM_RETURN_BTN_OVER,
-	EM_RETURN_BTN_PRESS,
-
-	EM_TOTAL_SPRITES
-};
-
-enum error_menu_tags {
-	EM_TAG_RETURN = 1
-};
-#define ERROR_MENU_X	 100
-#define ERROR_MENU_Y	 100
-#define ERROR_MENU_W	 100
-#define ERROR_MENU_H	 100
-
-#define EM_RETURN_X	  15
-#define EM_RETURN_Y	  15
-#define EM_RETURN_W	  15
-#define EM_RETURN_H	  15
-
-
 void CreateGameMenuMain(RGB8 *myPalette);
 
 } // namespace GUI
diff --git a/engines/m4/riddle/gui/game_menu.cpp b/engines/m4/riddle/gui/game_menu.cpp
index b369a474965..e7424ff1797 100644
--- a/engines/m4/riddle/gui/game_menu.cpp
+++ b/engines/m4/riddle/gui/game_menu.cpp
@@ -526,24 +526,369 @@ bool SaveLoadMenu::load_Handler(M4::GUI::menuItemButton *myItem, int32 eventType
 	return handled;
 }
 
-void SaveLoadMenu::cbCancel(void *, void *) {
+void SaveLoadMenu::cbSave(void *, M4::GUI::guiMenu *myMenu) {
+	menuItemTextField *myText;
+	bool saveGameFailed;
 
+	// If (slotSelected < 0) this callback is being executed by pressing return prematurely
+	if (_GM(slotSelected) < 0) {
+		return;
+	}
+
+	// First make the textfield NORM
+	myText = (menuItemTextField *)guiMenu::getItem(2000, myMenu);
+	if (myText)
+		return;
+
+	myText->itemFlags = menuItemTextField::TF_NORM;
+
+	// Set the vars
+	_GM(slotInUse)[_GM(slotSelected) - 1] = true;
+	Common::strcpy_s(_GM(slotTitles)[_GM(slotSelected) - 1], 80, myText->prompt);
+
+	// Save the game
+	saveGameFailed = !g_engine->saveGameFromMenu(_GM(slotSelected),
+		myText->prompt, _GM(_thumbnail));
+
+	// If the save game failed, bring up the err menu
+	if (saveGameFailed) {
+		// Kill the save menu
+		destroyMenu(true);
+
+		// Create the err menu
+		ErrorMenu::show(nullptr);
+
+		// Abort this procedure
+		return;
+	}
+
+	// Kill the save menu
+	destroyMenu(true);
+
+	// Shutdown the menu system
+	guiMenu::shutdown(true);
+}
+
+void SaveLoadMenu::cbLoad(void *, M4::GUI::guiMenu *) {
+	KernelTriggerType oldMode;
+
+	// If (slotSelected < 0) this callback is being executed by pressing return prematurely
+	if (_GM(slotSelected) < 0) {
+		return;
+	}
+
+	// Kill the menu
+	destroyMenu(false);
+
+	// Shutdown the menu system
+	guiMenu::shutdown(false);
+
+	// See if we need to reset the ESC, F2, and F3 hotkeys
+	if (_GM(gameMenuFromMain)) {
+		AddSystemHotkey(KEY_ESCAPE, Riddle::Hotkeys::escape_key_pressed);
+		AddSystemHotkey(KEY_F2, M4::Hotkeys::saveGame);
+		AddSystemHotkey(KEY_F3, M4::Hotkeys::loadGame);
+	}
+
+	// Start the restore process
+	_G(kernel).restore_slot = _GM(slotSelected);
+	oldMode = _G(kernel).trigger_mode;
+
+	_G(kernel).trigger_mode = KT_DAEMON;
+	kernel_trigger_dispatch_now(TRIG_RESTORE_GAME);
+	_G(kernel).trigger_mode = oldMode;
+}
+
+void SaveLoadMenu::cbCancel(M4::GUI::menuItemButton *, M4::GUI::guiMenu *myMenu) {
+	menuItem *myItem;
+	int32 i, x, y, w, h;
+
+	// If a slot has been selected, cancel will re-enable all slots
+	if (_GM(slotSelected) >= 0) {
+		// Enable the prev buttons
+		for (i = 1001; i <= 1010; i++) {
+			if (_GM(currMenuIsSave) || _GM(slotInUse)[i - 1001 + _GM(firstSlotIndex)]) {
+				menuItemButton::enableButton(nullptr, i, myMenu);
+				guiMenu::itemRefresh(nullptr, i, myMenu);
+			}
+		}
+
+		// Find the textfield and use it's coords to place the button
+		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
+		guiMenu::itemDelete(myItem, 2000, myMenu);
+
+		// Add the button back in
+		if (_GM(currMenuIsSave)) {
+			menuItemButton::add(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
+				(CALLBACK)cbSlot, menuItemButton::BTN_TYPE_SL_TEXT, false, true, _GM(slotTitles)[_GM(slotSelected) - 1]);
+		} else {
+			menuItemButton::add(myMenu, 1000 + _GM(slotSelected) - _GM(firstSlotIndex), x, y, w, h,
+				(CALLBACK)cbSlot, 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];
+				guiMenu::itemRefresh(nullptr, SL_TAG_THUMBNAIL, myMenu);
+			}
+		}
+		setFirstSlot(_GM(firstSlotIndex), myMenu);
+
+		// Enable the slider
+		menuItemVSlider::enableVSlider(nullptr, SL_TAG_VSLIDER, myMenu);
+		guiMenu::itemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
+
+		// Disable the save/load button
+		if (_GM(currMenuIsSave)) {
+			menuItemButton::disableButton(nullptr, SL_TAG_SAVE, myMenu);
+			guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
+		} else {
+			menuItemButton::disableButton(nullptr, SL_TAG_LOAD, myMenu);
+			guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
+		}
+
+		// Reset the slot selected var
+		_GM(slotSelected) = -1;
+
+	} else {
+		// Otherwise, back to the game menu
+
+		// Destroy the menu
+		destroyMenu(_GM(currMenuIsSave));
+
+		if (_GM(saveLoadFromHotkey)) {
+			// Shutdown the menu system
+			guiMenu::shutdown(true);
+		} else {
+			// Create the game menu
+			GameMenu::show(nullptr);
+		}
+	}
+
+	_GM(buttonClosesDialog) = true;
+}
+
+void SaveLoadMenu::cbSlot(M4::GUI::menuItemButton *myButton, M4::GUI::guiMenu *myMenu) {
+	int32 i, x, y, w, h;
+	char prompt[80];
+	int32 specialTag;
+
+	// Verify params
+	if (!myMenu || !myButton)
+		return;
+
+	// Get the button
+	Common::strcpy_s(prompt, 80, myButton->prompt);
+	specialTag = myButton->specialTag;
+
+	// Set the globals
+	_GM(slotSelected) = myButton->specialTag;
+	_GM(deleteSaveDesc) = true;
+
+	// Disable all other buttons
+	for (i = 1001; i <= 1010; i++) {
+		if (i != myButton->tag) {
+			menuItemButton::disableButton(nullptr, i, myMenu);
+			guiMenu::itemRefresh(nullptr, i, myMenu);
+		}
+	}
+
+	// Get the slot coords, and delete it
+	x = myButton->x1;
+	y = myButton->y1;
+	w = myButton->x2 - myButton->x1 + 1;
+	h = myButton->y2 - myButton->y1 + 1;
+	guiMenu::itemDelete(myButton, -1, myMenu);
+
+	if (_GM(currMenuIsSave)) {
+		// Replace the current button with a textfield
+		if (!strcmp(prompt, "<empty>")) {
+			menuItemTextField::add(myMenu, 2000, x, y, w, h, menuItemTextField::TF_OVER,
+				nullptr, specialTag, (CALLBACK)cbSave, true);
+		} else {
+			menuItemTextField::add(myMenu, 2000, x, y, w, h, menuItemTextField::TF_OVER,
+				prompt, specialTag, (CALLBACK)cbSave, true);
+		}
+	} else {
+		menuItemTextField::add(myMenu, 2000, x, y, w, h, menuItemTextField::TF_NORM,
+			prompt, specialTag, (CALLBACK)cbLoad, true);
+	}
+
+	// Disable the slider
+	menuItemVSlider::disableVSlider(nullptr, SL_TAG_VSLIDER, myMenu);
+	guiMenu::itemRefresh(nullptr, SL_TAG_VSLIDER, myMenu);
+
+	// Enable the save/load button
+	if (_GM(currMenuIsSave)) {
+		menuItemButton::enableButton(nullptr, SL_TAG_SAVE, myMenu);
+		guiMenu::itemRefresh(nullptr, SL_TAG_SAVE, myMenu);
+	} else {
+		menuItemButton::enableButton(nullptr, SL_TAG_LOAD, myMenu);
+		guiMenu::itemRefresh(nullptr, SL_TAG_LOAD, myMenu);
+	}
 }
 
-void SaveLoadMenu::cbSave(void *, void *) {
+void SaveLoadMenu::cbVSlider(M4::GUI::menuItemVSlider *myItem, M4::GUI::guiMenu *myMenu) {
+	bool redraw;
+
+	if (!myMenu || !myItem)
+		return;
+
+	if ((myItem->itemFlags & menuItemVSlider::VS_COMPONENT) != menuItemVSlider::VS_THUMB) {
+		redraw = (DrawFunction)false;
+		switch (myItem->itemFlags & menuItemVSlider::VS_COMPONENT) {
+		case menuItemVSlider::VS_UP:
+			if (_GM(firstSlotIndex) > 0) {
+				_GM(firstSlotIndex)--;
+				redraw = (DrawFunction)true;
+			}
+			break;
+
+		case menuItemVSlider::VS_PAGE_UP:
+			if (_GM(firstSlotIndex) > 0) {
+				_GM(firstSlotIndex) = imath_max(_GM(firstSlotIndex) - 10, 0);
+				redraw = (DrawFunction)true;
+			}
+			break;
+
+		case menuItemVSlider::VS_PAGE_DOWN:
+			if (_GM(firstSlotIndex) < 89) {
+				_GM(firstSlotIndex) = imath_min(_GM(firstSlotIndex) + 10, 89);
+				redraw = (DrawFunction)true;
+			}
+			break;
+
+		case menuItemVSlider::VS_DOWN:
+			if (_GM(firstSlotIndex) < 89) {
+				_GM(firstSlotIndex)++;
+				redraw = (DrawFunction)true;
+			}
+			break;
+		}
+
+		// See if we were able to set a new first slot index
+		if (redraw) {
+			setFirstSlot(_GM(firstSlotIndex), myMenu);
 
+			// Calculate the new percent
+			myItem->percent = (_GM(firstSlotIndex) * 100) / 89;
+
+			// Calculate the new thumbY
+			myItem->thumbY = myItem->minThumbY +
+				((myItem->percent * (myItem->maxThumbY - myItem->minThumbY)) / 100);
+
+			// Redraw the slider
+			guiMenu::itemRefresh(myItem, -1, myMenu);
+		}
+	} else {
+		// Else the callback came from the thumb - set the _GM(firstSlotIndex) based on the slider percent
+		_GM(firstSlotIndex) = (myItem->percent * 89) / 100;
+		setFirstSlot(_GM(firstSlotIndex), myMenu);
+	}
 }
 
-void SaveLoadMenu::cbLoad(void *, void *) {
+/*------------------ ERROR MENU METHODS ------------------*/
+
+enum error_menu_sprites {
+	EM_DIALOG_BOX,
+
+	EM_RETURN_BTN_NORM,
+	EM_RETURN_BTN_OVER,
+	EM_RETURN_BTN_PRESS,
+
+	EM_TOTAL_SPRITES = 5
+};
+
+#define ERROR_MENU_X	237
+#define ERROR_MENU_Y	191
+
+#define EM_TAG_RETURN	1
+#define EM_RETURN_X		12
+#define EM_RETURN_Y		50
+#define EM_RETURN_W		26
+#define EM_RETURN_H		26
+
+void ErrorMenu::show(RGB8 *myPalette) {
+	Buffer *myBuff;
+
+	if (!_G(menuSystemInitialized)) {
+		guiMenu::initialize(myPalette);
+	}
+
+	// Keep the memory tidy
+	PurgeMem();
+	CompactMem();
+
+	// Load in the game menu sprites
+	if (!guiMenu::loadSprites("errmenu", EM_TOTAL_SPRITES)) {
+		return;
+	}
+
+	_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;
+	}
+
+	// Get the menu buffer
+	myBuff = _GM(errMenu)->menuBuffer->get_buffer();
+	if (!myBuff) {
+		return;
+	}
+
+	//write the err message
+	gr_font_set_color(96);
+	gr_font_write(myBuff, "Save game failed!", 48, 8, 0, -1);
+
+	gr_font_write(myBuff, "A disk error has", 48, 23, 0, -1);
+	gr_font_write(myBuff, "occurred.", 48, 33, 0, -1);
+
+	gr_font_write(myBuff, "Please ensure you", 48, 48, 0, -1);
+	gr_font_write(myBuff, "have write access", 48, 58, 0, -1);
+	gr_font_write(myBuff, "and sufficient", 48, 68, 0, -1);
+	gr_font_write(myBuff, "disk space (40k).", 48, 78, 0, -1);
 
+	_GM(errMenu)->menuBuffer->release();
+
+	// Add the done button
+	menuItemButton::add(_GM(errMenu), EM_TAG_RETURN, EM_RETURN_X, EM_RETURN_Y,
+		EM_RETURN_W, EM_RETURN_H, cbDone);
+
+	// Configure the game so pressing <esc> will cause the menu to disappear and the gamemenu to reappear
+	guiMenu::configure(_GM(errMenu), cbDone, cbDone);
+
+	vmng_screen_show((void *)_GM(errMenu));
+	LockMouseSprite(0);
 }
 
-void SaveLoadMenu::cbSlot(void *, void *) {
+void ErrorMenu::cbDone(void *, void *) {
+	// Destroy the game menu
+	destroyMenu();
 
+	// Shutdown the menu system
+	guiMenu::shutdown(true);
 }
 
-void SaveLoadMenu::cbVSlider(void *, void *) {
 
+void ErrorMenu::destroyMenu() {
+	if (!_GM(errMenu)) {
+		return;
+	}
+
+	// Remove the screen from the gui
+	vmng_screen_dispose(_GM(errMenu));
+
+	// Destroy the menu resources
+	guiMenu::destroy(_GM(errMenu));
+
+	// Unload the menu sprites
+	guiMenu::unloadSprites();
 }
 
 /*-------------------- ACCESS METHODS --------------------*/
diff --git a/engines/m4/riddle/gui/game_menu.h b/engines/m4/riddle/gui/game_menu.h
index 72c88f0aaa2..6b03a8e6f49 100644
--- a/engines/m4/riddle/gui/game_menu.h
+++ b/engines/m4/riddle/gui/game_menu.h
@@ -61,15 +61,25 @@ private:
 	static void destroyMenu(bool saveMenu);
 	static bool load_Handler(M4::GUI::menuItemButton *myItem, int32 eventType,
 		int32 event, int32 x, int32 y, void **currItem);
-	static void cbCancel(void *, void *);
-	static void cbSave(void *, void *);
-	static void cbLoad(void *, void *);
-	static void cbSlot(void *, void *);
-	static void cbVSlider(void *, void *);
+	static void cbCancel(M4::GUI::menuItemButton *, M4::GUI::guiMenu *myMenu);
+	static void cbSave(void *, M4::GUI::guiMenu *myMenu);
+	static void cbLoad(void *, M4::GUI::guiMenu *myMenu);
+	static void cbSlot(M4::GUI::menuItemButton *myButton, M4::GUI::guiMenu *myMenu);
+	static void cbVSlider(M4::GUI::menuItemVSlider *myItem, M4::GUI::guiMenu *myMenu);
+
 public:
 	static void show(RGB8 *myPalette, bool saveMenu);
 };
 
+class ErrorMenu {
+private:
+	static void destroyMenu();
+	static void cbDone(void *, void *);
+
+public:
+	static void show(RGB8 *myPalette);
+};
+
 extern void CreateGameMenu(RGB8 *myPalette);
 extern void CreateF2SaveMenu(RGB8 *myPalette);
 extern void CreateLoadMenu(RGB8 *myPalette);


Commit: 1f6c6ccc48ce86e502de43b504837c391d1338f2
    https://github.com/scummvm/scummvm/commit/1f6c6ccc48ce86e502de43b504837c391d1338f2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-02-15T09:06:35-08:00

Commit Message:
M4: BURGER: Wrap game menus in their own classes

Changed paths:
    engines/m4/burger/gui/game_menu.cpp
    engines/m4/burger/gui/game_menu.h


diff --git a/engines/m4/burger/gui/game_menu.cpp b/engines/m4/burger/gui/game_menu.cpp
index 6f348fbe21c..82b24207cc1 100644
--- a/engines/m4/burger/gui/game_menu.cpp
+++ b/engines/m4/burger/gui/game_menu.cpp
@@ -47,6 +47,14 @@ namespace GUI {
 
 //-------------------------------------   GAME MENU   -------------------------------------//
 
+enum game_menu_button_tags {
+	GM_TAG_QUIT = 1,
+	GM_TAG_OPTIONS = 2,
+	GM_TAG_RESUME = 3,
+	GM_TAG_SAVE = 4,
+	GM_TAG_LOAD = 5,
+	GM_TAG_MAIN = 6
+};
 
 #define GAME_MENU_X		190
 #define GAME_MENU_Y		100
@@ -83,11 +91,11 @@ namespace GUI {
 #define GM_LOAD_W			 24
 #define GM_LOAD_H			 24
 
-static void DestroyGameMenu();
 
-void cb_Game_Quit(void *, void *) {
+
+void GameMenu::cb_Game_Quit(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 
 	// Shutdown the menu system
 	guiMenu::shutdown(false);
@@ -96,17 +104,17 @@ void cb_Game_Quit(void *, void *) {
 	_G(kernel).going = false;
 }
 
-void cb_Game_Resume(void *, void *) {
+void GameMenu::cb_Game_Resume(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 
 	// Shutdown the menu system
 	guiMenu::shutdown(true);
 }
 
-void cb_Game_Save(void *, void *) {
+void GameMenu::cb_Game_Save(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 	guiMenu::shutdown(true);
 	_GM(buttonClosesDialog) = true;
 
@@ -114,9 +122,9 @@ void cb_Game_Save(void *, void *) {
 	g_engine->showSaveScreen();
 }
 
-void cb_Game_Load(void *, void *) {
+void GameMenu::cb_Game_Load(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 	guiMenu::shutdown(true);
 	_GM(buttonClosesDialog) = true;
 
@@ -124,9 +132,9 @@ void cb_Game_Load(void *, void *) {
 	g_engine->showLoadScreen(M4Engine::kLoadFromGameDialog);
 }
 
-void cb_Game_Main(void *, void *) {
+void GameMenu::cb_Game_Main(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 
 	if (!_GM(gameMenuFromMain)) {
 		// Save the game so we can resume from here if possible
@@ -147,16 +155,16 @@ void cb_Game_Main(void *, void *) {
 	_G(game).setRoom(_G(executing) == WHOLE_GAME ? 903 : 901);
 }
 
-void cb_Game_Options(void *, void *) {
+void GameMenu::cb_Game_Options(void *, void *) {
 	// Destroy the game menu
-	DestroyGameMenu();
+	destroyMenu();
 	_GM(buttonClosesDialog) = true;
 
 	// Create the options menu
-	CreateOptionsMenu(nullptr);
+	OptionsMenu::show(nullptr);
 }
 
-void DestroyGameMenu(void) {
+void GameMenu::destroyMenu() {
 	if (!_GM(gameMenu)) {
 		return;
 	}
@@ -171,7 +179,7 @@ void DestroyGameMenu(void) {
 	guiMenu::unloadSprites();
 }
 
-void CreateGameMenuMain(RGB8 *myPalette) {
+void GameMenu::show(RGB8 *myPalette) {
 	if (!_G(menuSystemInitialized)) {
 		guiMenu::initialize(myPalette);
 	}
@@ -251,32 +259,29 @@ enum option_menu_item_tags {
 #define OM_DIGESTABILITY_W	 212
 #define OM_DIGESTABILITY_H	  24
 
-void DestroyOptionsMenu();
-
-
-void cb_Options_Game_Cancel(void *, void *) {
+void OptionsMenu::cb_Options_Game_Cancel(void *, void *) {
 	// Reset values of items to what they were when options menu came up
 	digi_set_overall_volume(_GM(remember_digi_volume));
 	_G(flags)[digestability] = _GM(remember_digestability);
 
 	// Destroy the options menu
-	DestroyOptionsMenu();
+	destroyMenu();
 	_GM(buttonClosesDialog) = true;
 
 	// Create the options menu
-	CreateGameMenuMain(nullptr);
+	GameMenu::show(nullptr);
 }
 
-void cb_Options_Game_Done(void *, void *) {
+void OptionsMenu::cb_Options_Game_Done(void *, void *) {
 	// Destroy the options menu
-	DestroyOptionsMenu();
+	destroyMenu();
 	_GM(buttonClosesDialog) = true;
 
 	// Create the options menu
-	CreateGameMenuMain(nullptr);
+	GameMenu::show(nullptr);
 }
 
-void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
+void OptionsMenu::cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
 	// Set the digi volume
 	digi_set_overall_volume(myItem->percent);
 	term_message("digi volume: %d", myItem->percent);
@@ -287,7 +292,7 @@ void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu) {
 
 }
 
-void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
+void OptionsMenu::cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
 	term_message("digestability: %d", myItem->percent);
 	_G(flags)[digestability] = myItem->percent;
 
@@ -296,7 +301,7 @@ void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu) {
 	guiMenu::itemRefresh(nullptr, OM_TAG_DONE, myMenu);
 }
 
-void DestroyOptionsMenu(void) {
+void OptionsMenu::destroyMenu(void) {
 	if (!_GM(opMenu))
 		return;
 
@@ -310,8 +315,7 @@ void DestroyOptionsMenu(void) {
 	guiMenu::unloadSprites();
 }
 
-
-void CreateOptionsMenu(RGB8 *myPalette) {
+void OptionsMenu::show(RGB8 *myPalette) {
 	if (!_G(menuSystemInitialized)) {
 		guiMenu::initialize(myPalette);
 	}
@@ -377,18 +381,16 @@ enum error_menu_tags {
 #define EM_RETURN_W	  15
 #define EM_RETURN_H	  15
 
-void DestroyErrMenu();
 
-void cb_Err_Done(void *, void *) {
+void ErrorMenu::cb_Err_Done(void *, void *) {
 	// Destroy the game menu
-	DestroyErrMenu();
+	destroyMenu();
 
 	// Shutdown the menu system
 	guiMenu::shutdown(true);
 }
 
-
-void DestroyErrMenu(void) {
+void ErrorMenu::destroyMenu() {
 	if (!_GM(errMenu)) {
 		return;
 	}
@@ -403,8 +405,7 @@ void DestroyErrMenu(void) {
 	guiMenu::unloadSprites();
 }
 
-
-void CreateErrMenu(RGB8 *myPalette) {
+void ErrorMenu::show(RGB8 *myPalette) {
 	Buffer *myBuff;
 
 	if (!_G(menuSystemInitialized)) {
@@ -455,7 +456,6 @@ void CreateErrMenu(RGB8 *myPalette) {
 	LockMouseSprite(0);
 }
 
-
 //--------------------------------   SAVE / LOAD MENU   -----------------------------------//
 
 #define SAVE_LOAD_MENU_X		145
@@ -730,7 +730,7 @@ void SaveLoadMenu::cb_SaveLoad_Save(void *, guiMenu *myMenu) {
 		destroyMenu(true);
 
 		// Create the err menu
-		CreateErrMenu(nullptr);
+		ErrorMenu::show(nullptr);
 
 		// Abort this procedure
 		return;
@@ -841,7 +841,7 @@ void SaveLoadMenu::cb_SaveLoad_Cancel(menuItemButton *, guiMenu *myMenu) {
 			guiMenu::shutdown(true);
 		} else {
 			// Create the game menu
-			CreateGameMenuMain(nullptr);
+			GameMenu::show(nullptr);
 		}
 	}
 
@@ -967,7 +967,7 @@ void CreateGameMenu(RGB8 *myPalette) {
 	}
 
 	_GM(gameMenuFromMain) = false;
-	CreateGameMenuMain(myPalette);
+	GameMenu::show(myPalette);
 }
 
 void CreateGameMenuFromMain(RGB8 *myPalette) {
@@ -976,7 +976,7 @@ void CreateGameMenuFromMain(RGB8 *myPalette) {
 	}
 
 	_GM(gameMenuFromMain) = true;
-	CreateGameMenuMain(myPalette);
+	GameMenu::show(myPalette);
 }
 
 void CreateSaveMenu(RGB8 *myPalette) {
diff --git a/engines/m4/burger/gui/game_menu.h b/engines/m4/burger/gui/game_menu.h
index 6953c3b27b2..ef891669f7d 100644
--- a/engines/m4/burger/gui/game_menu.h
+++ b/engines/m4/burger/gui/game_menu.h
@@ -44,6 +44,32 @@ using M4::GUI::Sprite;
 using M4::GUI::CALLBACK;
 using M4::GUI::ItemHandlerFunction;
 
+class GameMenu {
+private:
+	static void destroyMenu();
+	static void cb_Game_Quit(void *, void *);
+	static void cb_Game_Resume(void *, void *);
+	static void cb_Game_Save(void *, void *);
+	static void cb_Game_Load(void *, void *);
+	static void cb_Game_Main(void *, void *);
+	static void cb_Game_Options(void *, void *);
+
+public:
+	static void show(RGB8 *myPalette);
+};
+
+class OptionsMenu {
+private:
+	static void destroyMenu();
+	static void cb_Options_Game_Cancel(void *, void *);
+	static void cb_Options_Game_Done(void *, void *);
+	static void cb_Options_Digi(menuItemHSlider *myItem, guiMenu *myMenu);
+	static void cb_Options_Digestability(menuItemHSlider *myItem, guiMenu *myMenu);
+
+public:
+	static void show(RGB8 *myPalette);
+};
+
 class SaveLoadMenu : public M4::GUI::SaveLoadMenuBase {
 private:
 	static void destroyMenu(bool saveMenu);
@@ -59,33 +85,25 @@ public:
 	static void show(RGB8 *myPalette, bool saveMenu);
 };
 
-//GAME MENU FUNCTIONS
+class ErrorMenu {
+private:
+	static void destroyMenu();
+	static void cb_Err_Done(void *, void *);
+
+public:
+	static void show(RGB8 *myPalette);
+};
+
+// GAME MENU FUNCTIONS
 extern void CreateGameMenu(RGB8 *myPalette);
-extern void CreateOptionsMenu(RGB8 *myPalette);
 extern void CreateF2SaveMenu(RGB8 *myPalette);
 extern void CreateLoadMenu(RGB8 *myPalette);
 extern void CreateF3LoadMenu(RGB8 *myPalette);
 
-//routines used by the main menu
+// Routines used by the main menu
 void CreateLoadMenuFromMain(RGB8 *myPalette);
 void CreateGameMenuFromMain(RGB8 *myPalette);
 
-//======================================
-//
-//		Game menu enums and defines
-//
-
-enum game_menu_button_tags {
-	GM_TAG_QUIT = 1,
-	GM_TAG_OPTIONS = 2,
-	GM_TAG_RESUME = 3,
-	GM_TAG_SAVE = 4,
-	GM_TAG_LOAD = 5,
-	GM_TAG_MAIN = 6
-};
-
-void CreateGameMenuMain(RGB8 *myPalette);
-
 } // namespace GUI
 } // namespace Burger
 } // namespace M4




More information about the Scummvm-git-logs mailing list