From 8a2e03c9cbba5ef2434bf17cd8f98c58a829d142 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 23 Jul 2009 04:33:07 +0000 Subject: [PATCH] - Fixed: Redefining an existing skill would set that skills ACSReturn to be the same as the next new skill defined, if neither definition explicitly set the value for ACSReturn. - Added a DefaultSkill property. Adding it to a skill will cause that skill to be the default one selected in the menu. If none is specified as the default, then the middle skill is the default. SVN r1731 (trunk) --- docs/rh-log.txt | 6 ++++++ src/g_level.h | 1 + src/g_mapinfo.cpp | 3 ++- src/g_skill.cpp | 30 +++++++++++++++++++++++++++- src/info.cpp | 2 -- src/m_menu.cpp | 28 ++++++++++++++++++++------ wadsrc/static/mapinfo/doomcommon.txt | 3 +-- wadsrc/static/mapinfo/heretic.txt | 1 + wadsrc/static/mapinfo/hexen.txt | 1 + wadsrc/static/mapinfo/strife.txt | 1 + 10 files changed, 64 insertions(+), 12 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 10837fedbc..0fe1b87573 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ July 22, 2009 +- Fixed: Redefining an existing skill would set that skills ACSReturn to be + the same as the next new skill defined, if neither definition explicitly set + the value for ACSReturn. +- Added a DefaultSkill property. Adding it to a skill will cause that skill + to be the default one selected in the menu. If none is specified as the + default, then the middle skill is the default. - Slider controls in the options menu now display their values numerically next to the slider. - The minimum value for m_yaw, m_pitch, m_forward, and m_side from the diff --git a/src/g_level.h b/src/g_level.h index bbdc3c2cff..01d3e91e43 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -580,6 +580,7 @@ struct FSkillInfo }; extern TArray AllSkills; +extern int DefaultSkill; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index c591270fd6..736c568cd5 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1851,6 +1851,7 @@ void FMapInfoParser::ParseMapInfo (int lump, level_info_t &gamedefaults, level_i else if (sc.Compare("clearskills")) { AllSkills.Clear(); + DefaultSkill = -1; } else if (sc.Compare("gameinfo")) { @@ -1908,7 +1909,7 @@ void G_ParseMapInfo (const char *basemapinfo) { I_FatalError ("You cannot use clearepisodes in a MAPINFO if you do not define any new episodes after it."); } - if (AllSkills.Size()==0) + if (AllSkills.Size() == 0) { I_FatalError ("You cannot use clearskills in a MAPINFO if you do not define any new skills after it."); } diff --git a/src/g_skill.cpp b/src/g_skill.cpp index cefef38932..203acdb46d 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -42,6 +42,7 @@ #include "v_font.h" TArray AllSkills; +int DefaultSkill = -1; //========================================================================== // @@ -52,6 +53,8 @@ TArray AllSkills; void FMapInfoParser::ParseSkill () { FSkillInfo skill; + bool thisisdefault = false; + bool acsreturnisset = false; skill.AmmoFactor = FRACUNIT; skill.DoubleAmmoFactor = 2*FRACUNIT; @@ -65,7 +68,7 @@ void FMapInfoParser::ParseSkill () skill.RespawnLimit = 0; skill.Aggressiveness = FRACUNIT; skill.SpawnFilter = 0; - skill.ACSReturn = AllSkills.Size(); + skill.ACSReturn = 0; skill.MenuNameIsLump = false; skill.MustConfirm = false; skill.Shortcut = 0; @@ -163,6 +166,7 @@ void FMapInfoParser::ParseSkill () ParseAssign(); sc.MustGetNumber (); skill.ACSReturn = sc.Number; + acsreturnisset = true; } else if (sc.Compare("ReplaceActor")) { @@ -245,6 +249,14 @@ void FMapInfoParser::ParseSkill () { skill.NoPain = true; } + else if (sc.Compare("DefaultSkill")) + { + if (DefaultSkill >= 0) + { + sc.ScriptError("%s is already the default skill\n", AllSkills[DefaultSkill].Name.GetChars()); + } + thisisdefault = true; + } else if (!ParseCloseBrace()) { // Unknown @@ -261,10 +273,26 @@ void FMapInfoParser::ParseSkill () { if (AllSkills[i].Name == skill.Name) { + if (!acsreturnisset) + { // Use the ACS return for the skill we are overwriting. + skill.ACSReturn = AllSkills[i].ACSReturn; + } AllSkills[i] = skill; + if (thisisdefault) + { + DefaultSkill = i; + } return; } } + if (!acsreturnisset) + { + skill.ACSReturn = AllSkills.Size(); + } + if (thisisdefault) + { + DefaultSkill = AllSkills.Size(); + } AllSkills.Push(skill); } diff --git a/src/info.cpp b/src/info.cpp index aec4f717e3..10fb568f26 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -52,8 +52,6 @@ extern void LoadActors (); -extern TArray AllSkills; - //========================================================================== // diff --git a/src/m_menu.cpp b/src/m_menu.cpp index 274bdf5907..cc21a94c95 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -418,19 +418,19 @@ static oldmenuitem_t SkillSelectMenu[]={ static oldmenu_t SkillDef = { 0, - SkillSelectMenu, // oldmenuitem_t -> + SkillSelectMenu, // oldmenuitem_t -> M_DrawNewGame, // drawing routine -> 48,63, // x,y - 2 // lastOn + -1 // lastOn }; static oldmenu_t HexenSkillMenu = { 0, - SkillSelectMenu, // oldmenuitem_t -> + SkillSelectMenu, DrawHexenSkillMenu, 120, 44, - 2 + -1 }; @@ -453,7 +453,7 @@ void M_StartupSkillMenu(const char *playerclass) } } SkillDef.numitems = HexenSkillMenu.numitems = 0; - for(unsigned int i=0;i= AllSkills.Size()) + { + defskill = (AllSkills.Size() - 1) / 2; + } + // The default skill is only set the first time the menu is opened. + // After that, it opens on whichever skill you last selected. + if (SkillDef.lastOn < 0) + { + SkillDef.lastOn = defskill; + } + if (HexenSkillMenu.lastOn < 0) + { + HexenSkillMenu.lastOn = defskill; + } // Hexen needs some manual coordinate adjustments based on player class if (gameinfo.gametype == GAME_Hexen) { M_SetupNextMenu(&HexenSkillMenu); } else + { M_SetupNextMenu(&SkillDef); + } } @@ -1629,7 +1646,6 @@ void M_NewGame(int choice) { M_StartupSkillMenu(NULL); } - } else { diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index a545da8c19..0d91265f9c 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -1,4 +1,3 @@ - gameinfo { titlepage = "TITLEPIC" @@ -59,6 +58,7 @@ skill normal SpawnFilter = Normal PicName = "M_HURT" Key = "h" + DefaultSkill } skill hard @@ -79,4 +79,3 @@ skill nightmare MustConfirm Key = "n" } - diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index 93dc98e98a..057512d20b 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -58,6 +58,7 @@ skill normal DoubleAmmoFactor = 1.5 SpawnFilter = Normal Name = "$MNU_BRINGEST" + DefaultSkill } skill hard diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index 547b6d4f67..9df6a7cefa 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -67,6 +67,7 @@ skill normal playerclassname = "fighter", "$MNU_WARRIOR" playerclassname = "cleric", "$MNU_PRIEST" playerclassname = "mage", "$MNU_SORCERER" + DefaultSkill } skill hard diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index ef3a66f8fd..59a15f1b0d 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -59,6 +59,7 @@ skill normal SpawnFilter = Normal PicName = "M_HURT" Key = "v" + DefaultSkill } skill hard