From dc6b45804d22ea84d2f7a506c4bc2ac79d87a9be Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 31 Jan 2015 20:10:18 -0600 Subject: [PATCH 1/5] Don't lose the cursor when scrolling up in option menus - Fixed: If the menu cursor was on the topmost-displayed item, pressing up would not scroll the view up. The check for scrolling only tested if the newly selected item was the topmost one, since the menu code had assumed the only time the cursor would be on the topmost visible line was when it was the very first line of the menu. Using PgDn breaks this assumption. --- src/menu/optionmenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menu/optionmenu.cpp b/src/menu/optionmenu.cpp index eff53fc49..9a7715265 100644 --- a/src/menu/optionmenu.cpp +++ b/src/menu/optionmenu.cpp @@ -196,9 +196,9 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller) --mDesc->mSelectedItem; if (mDesc->mScrollPos > 0 && - mDesc->mSelectedItem == mDesc->mScrollTop + mDesc->mScrollPos) + mDesc->mSelectedItem <= mDesc->mScrollTop + mDesc->mScrollPos) { - mDesc->mScrollPos--; + mDesc->mScrollPos = MAX(mDesc->mSelectedItem - mDesc->mScrollTop - 1, 0); } if (mDesc->mSelectedItem < 0) From 8e1b1aa20150d4fb3340ceedc8bf9a615cef249d Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 2 Feb 2015 19:36:08 -0500 Subject: [PATCH 2/5] - Defer SDL subsystem initialization since it seems to cause conflicts with GUI toolkits on some systems. --- src/posix/sdl/hardware.cpp | 10 ++++++++++ src/posix/sdl/i_joystick.cpp | 11 ++++++++--- src/posix/sdl/i_main.cpp | 3 +-- src/posix/sdl/i_timer.cpp | 5 ++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 25e19ff21..75d663266 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -66,10 +66,20 @@ void I_ShutdownGraphics () } if (Video) delete Video, Video = NULL; + + SDL_QuitSubSystem (SDL_INIT_VIDEO); } void I_InitGraphics () { + if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) + { + I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError()); + return; + } + + Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); + UCVarValue val; val.Bool = !!Args->CheckParm ("-devparm"); diff --git a/src/posix/sdl/i_joystick.cpp b/src/posix/sdl/i_joystick.cpp index 9b1d326ae..d99caeca9 100644 --- a/src/posix/sdl/i_joystick.cpp +++ b/src/posix/sdl/i_joystick.cpp @@ -1,4 +1,4 @@ -#include +#include #include "doomdef.h" #include "templates.h" @@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager; void I_StartupJoysticks() { - JoystickManager = new SDLInputJoystickManager(); + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) + JoystickManager = new SDLInputJoystickManager(); } void I_ShutdownJoysticks() { - delete JoystickManager; + if(JoystickManager) + { + delete JoystickManager; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } } void I_GetJoysticks(TArray &sticks) diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index ff700eff4..d60494d1a 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -265,14 +265,13 @@ int main (int argc, char **argv) setlocale (LC_ALL, "C"); - if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1) + if (SDL_Init (0) < 0) { fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError()); return -1; } atterm (SDL_Quit); - printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); printf("\n"); try diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index e3f9906b6..6255c8a96 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms) void I_InitTimer () { + if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) + I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError()); + I_GetTime = I_GetTimeSelect; I_WaitForTic = I_WaitForTicSelect; I_FreezeTime = I_FreezeTimeSelect; @@ -202,5 +205,5 @@ void I_InitTimer () void I_ShutdownTimer () { - + SDL_QuitSubSystem(SDL_INIT_TIMER); } From de4097cc7bb7c84b7a1d241a9dab67eaa224fd94 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 14:52:52 +1300 Subject: [PATCH 3/5] Added INVENTORY.TRANSFER - INVENTORY.TRANSFER allows transferring all owned inventory to a new owner on pickup. --- src/g_shared/a_pickups.h | 2 +- src/p_mobj.cpp | 26 ++++++++++++++++++++++++++ src/thingdef/thingdef_data.cpp | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 8616393e7..df0c94b46 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -136,7 +136,7 @@ enum IF_NOSCREENFLASH = 1<<21, // No pickup flash on the player's screen IF_TOSSED = 1<<22, // Was spawned by P_DropItem (i.e. as a monster drop) IF_ALWAYSRESPAWN = 1<<23, // Always respawn, regardless of dmflag - + IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper }; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ef23ca0ba..b8e45278e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -551,12 +551,17 @@ void AActor::AddInventory (AInventory *item) { // Is it attached to us? if (item->Owner == this) + { + Printf("Crantech: AddInventory->%s->Owner was Owner\n", item->GetClass()->TypeName.GetChars()); return; + } // No, then remove it from the other actor first item->Owner->RemoveInventory (item); + Printf("Crantech: AddInventory->%s->Owner was nonNULL\n", item->GetClass()->TypeName.GetChars()); } + TObjPtr Invstack = item->Inventory; item->Owner = this; item->Inventory = Inventory; Inventory = item; @@ -567,6 +572,26 @@ void AActor::AddInventory (AInventory *item) // run sometime in the future, so by the time it runs, the inventory // might not be in the same state as it was when DEM_INVUSE was sent. Inventory->InventoryID = InventoryID++; + + // If the flag exists, transfer all inventory accross that the old object had. + if ((item->ItemFlags & IF_TRANSFER)) + { + while (Invstack) + { + AInventory* titem = Invstack; + Invstack = titem->Inventory; + + Printf("Crantech: AddInventory->%s doing transfer of %s\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + bool success = titem->CallTryPickup(this); + if (!success) + { + Printf("Crantech: AddInventory->%s, %s is now being destroyed\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + titem->Destroy(); + } + //AddInventory(item->Inventory); // Adds current inventory item to present index + } + } + } //============================================================================ @@ -587,6 +612,7 @@ void AActor::RemoveInventory (AInventory *item) *invp = item->Inventory; item->DetachFromOwner (); item->Owner = NULL; + item->Inventory = NULL; break; } } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index fbe28fb5b..e91c2ee65 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -324,6 +324,7 @@ static FFlagDef InventoryFlags[] = DEFINE_FLAG(IF, NOSCREENFLASH, AInventory, ItemFlags), DEFINE_FLAG(IF, TOSSED, AInventory, ItemFlags), DEFINE_FLAG(IF, ALWAYSRESPAWN, AInventory, ItemFlags), + DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags), DEFINE_DEPRECATED_FLAG(PICKUPFLASH), DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),}; From 1e0a1466a3d873a0eeee2644eedcb32a5ebc9e42 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 20:13:54 +1300 Subject: [PATCH 4/5] Moved and rearranged transfer task - Some inventory pickup conditions weren't properly covered --- src/g_shared/a_pickups.cpp | 30 +++++++++++++++++++++++++++++- src/p_mobj.cpp | 25 ------------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 1aab998a9..1bdc69fba 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1372,6 +1372,8 @@ bool AInventory::TryPickupRestricted (AActor *&toucher) bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) { + TObjPtr Invstack = Inventory; // A pointer of the inventories item stack. + // unmorphed versions of a currently morphed actor cannot pick up anything. if (toucher->flags & MF_UNMORPHED) return false; @@ -1392,7 +1394,33 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) GoAwayAndDie(); } - if (res) GiveQuest(toucher); + if (res) + { + GiveQuest(toucher); + + // Transfer all inventory accross that the old object had, if requested. + if ((ItemFlags & IF_TRANSFER)) + { + while (Invstack) + { + AInventory* titem = Invstack; + Invstack = titem->Inventory; + if (titem->Owner == this) + { + Printf("Crantech: %s::CallTryPickup doing transfer of %s\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + if (!titem->CallTryPickup(toucher)) // The object no longer can exist + { + Printf("Crantech: %s::CallTryPickup, %s is now being destroyed\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + titem->Destroy(); + } + } + else + { + Printf("Crantech: %s::CallTryPickup, %s didn't belong to this object\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); + } + } + } + } return res; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b8e45278e..51c6407f9 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -551,17 +551,12 @@ void AActor::AddInventory (AInventory *item) { // Is it attached to us? if (item->Owner == this) - { - Printf("Crantech: AddInventory->%s->Owner was Owner\n", item->GetClass()->TypeName.GetChars()); return; - } // No, then remove it from the other actor first item->Owner->RemoveInventory (item); - Printf("Crantech: AddInventory->%s->Owner was nonNULL\n", item->GetClass()->TypeName.GetChars()); } - TObjPtr Invstack = item->Inventory; item->Owner = this; item->Inventory = Inventory; Inventory = item; @@ -572,26 +567,6 @@ void AActor::AddInventory (AInventory *item) // run sometime in the future, so by the time it runs, the inventory // might not be in the same state as it was when DEM_INVUSE was sent. Inventory->InventoryID = InventoryID++; - - // If the flag exists, transfer all inventory accross that the old object had. - if ((item->ItemFlags & IF_TRANSFER)) - { - while (Invstack) - { - AInventory* titem = Invstack; - Invstack = titem->Inventory; - - Printf("Crantech: AddInventory->%s doing transfer of %s\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - bool success = titem->CallTryPickup(this); - if (!success) - { - Printf("Crantech: AddInventory->%s, %s is now being destroyed\n", item->GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - titem->Destroy(); - } - //AddInventory(item->Inventory); // Adds current inventory item to present index - } - } - } //============================================================================ From 291861bf524d43c18f12a34462ed8c36a4486565 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Thu, 5 Feb 2015 23:53:34 +1300 Subject: [PATCH 5/5] Removed debug output --- src/g_shared/a_pickups.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 1bdc69fba..2888ea2b6 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1407,17 +1407,11 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return) Invstack = titem->Inventory; if (titem->Owner == this) { - Printf("Crantech: %s::CallTryPickup doing transfer of %s\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); if (!titem->CallTryPickup(toucher)) // The object no longer can exist { - Printf("Crantech: %s::CallTryPickup, %s is now being destroyed\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); titem->Destroy(); } } - else - { - Printf("Crantech: %s::CallTryPickup, %s didn't belong to this object\n", GetClass()->TypeName.GetChars(), titem->GetClass()->TypeName.GetChars()); - } } } }