diff --git a/resources/assets/mapinfo.gameinfo b/resources/assets/mapinfo.gameinfo index 3c03ddb..228d5e9 100644 --- a/resources/assets/mapinfo.gameinfo +++ b/resources/assets/mapinfo.gameinfo @@ -2,6 +2,7 @@ include mapinfo/heretic.mapinfo include mapinfo/hexen.mapinfo include mapinfo/hexdd.mapinfo include mapinfo/hxdd.mapinfo +include mapinfo/title.mapinfo GameInfo { titlepage = "TITLE" @@ -177,24 +178,36 @@ episode e1m1 { name = "$MNU_COTD" key = "c" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" } episode e2m1 { name = "$MNU_HELLSMAW" key = "h" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" } episode e3m1 { name = "$MNU_DOME" key = "d" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" } episode e4m1 { name = "$MNU_OSSUARY" key = "o" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" extended } @@ -202,6 +215,10 @@ episode e5m1 { name = "$MNU_DEMESNE" key = "s" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" + optional extended } @@ -209,6 +226,10 @@ episode e6m1 { name = "$MNU_FATEPTH" key = "f" + //gametype = "heretic" + //header = "$MNU_HEADER_HERETIC" + //description = "$MNU_STORY_HERETIC" + optional extended } @@ -216,13 +237,18 @@ episode MAP01 { name = "$MNU_HEXEN" key = "b" - optional + //gametype = "hexen" + //header = "$MNU_HEADER_HEXEN" + //description = "$MNU_STORY_HEXEN" } episode MAP50 { name = "$MNU_HEXDD" key = "k" + //gametype = "hexen" + //header = "$MNU_HEADER_HEXEN" + //description = "$MNU_STORY_HEXDD" optional } @@ -230,13 +256,17 @@ episode heretest { name = "HERETIC TEST" key = "1" + //gametype = "heretic" optional + //development } episode hextest { name = "HEXEN TEST" key = "2" + //gametype = "hexen" optional + //development } defaultmap diff --git a/resources/assets/zscript/lib/gameinforeader.zs b/resources/assets/zscript/lib/gameinforeader.zs index 7c555be..53107e8 100644 --- a/resources/assets/zscript/lib/gameinforeader.zs +++ b/resources/assets/zscript/lib/gameinforeader.zs @@ -33,18 +33,17 @@ class GameInfoReader { info.split(lines, "\n"); for (let i = 0; i < lines.Size(); i++) { - if (lines[i].IndexOf("PlayerClasses") != -1) { - String line = lines[i]; + String line = lines[i]; + if (line.IndexOf("PlayerClasses") != -1) { line.Substitute('"', ""); // remove quotes line.Substitute(" ", ""); // remove spaces - Array classLine; - line.split(classLine, "="); + Array split; + line.split(split, "="); - String lineClasses = classLine[classLine.Size() - 1]; + String lineClasses = split[split.Size() - 1]; lineClasses.split(classes, ","); - break; } } @@ -77,41 +76,33 @@ class GameInfoReader { if (idxSkill != -1 && idxBraceOpen != -1 && idxBraceClose != -1) { SkillInfo skInfo = new("SkillInfo"); - String between = minfo.Mid(idxBraceOpen, idxBraceClose); - - //console.printf("info %s", between); - - Array split; - between.split(split, "\n"); - for (int i = 0; i < split.Size(); i++) { - String line = split[i]; - - int idxQuoteOpen = line.IndexOf('"'); - String value = line.Mid(idxQuoteOpen + 1); - int idxQuoteClosed = value.IndexOf('"'); - value = value.Mid(0, idxQuoteClosed); + String strBlock = minfo.Mid(idxBraceOpen, idxBraceClose); + Array lines; + strBlock.split(lines, "\n"); + for (let i = 0; i < lines.Size(); i++) { + String line = lines[i]; if (line.MakeLower().IndexOf("playerclassname") != -1) { - String className = value; + line.Substitute('"', ""); // remove quotes + line.Substitute(" ", ""); // remove spaces + + Array split; + line.split(split, "="); - Array splitLine; - line.split(splitLine, ","); + String details = split[split.Size() - 1]; - String section = splitLine[splitLine.Size() - 1]; - idxQuoteOpen = section.IndexOf('"'); - String classSkill = section.Mid(idxQuoteOpen + 1); - idxQuoteClosed = classSkill.IndexOf('"'); - classSkill = classSkill.Mid(0, idxQuoteClosed); - console.printf("classSkill %s", classSkill); - - skInfo.classes.push(className); - skInfo.names.push(classSkill); - console.printf("class %s, skill %s", className, classSkill); + split.Clear(); + details.split(split, ","); + skInfo.classes.push(split[0]); + skInfo.names.push(split[1]); } else if (line.MakeLower().IndexOf("name") != -1) { - skInfo.name = value; - console.printf("skill %s", value); + line.Substitute('"', ""); // remove quotes + line.Substitute(" ", ""); // remove spaces + + Array split; + line.split(split, "="); + skInfo.name = split[1]; } - } self.skills.Push(skInfo); @@ -148,24 +139,27 @@ class GameInfoReader { if (idxEpisode != -1 && idxBraceOpen != -1 && idxBraceClose != -1) { EpisodeInfo epInfo = new("EpisodeInfo"); - String between = minfo.Mid(idxBraceOpen, idxBraceClose); + String strBlock = minfo.Mid(idxBraceOpen, idxBraceClose); - Array split; - between.split(split, "\n"); - for (int i = 0; i < split.Size(); i++) { - String line = split[i]; + Array lines; + strBlock.split(lines, "\n"); + for (int i = 0; i < lines.Size(); i++) { + String line = lines[i]; + + line.Substitute('"', ""); // remove quotes + line.Substitute(" ", ""); // remove spaces - int idxQuoteOpen = line.IndexOf('"'); - String value = line.Mid(idxQuoteOpen + 1); - int idxQuoteClosed = value.IndexOf('"'); + Array split; + line.split(split, "="); - value = value.Mid(0, idxQuoteClosed); if (line.IndexOf("name") != -1) { - epInfo.name = value; + epInfo.name = split[1]; + } else if (line.IndexOf("header") != -1) { + epInfo.header = split[1]; } else if (line.IndexOf("description") != -1) { - epInfo.description = value; + epInfo.description = split[1]; } else if (line.IndexOf("gametype") != -1) { - epInfo.gametype = value; + epInfo.gametype = split[1]; } else if (line.IndexOf("development")) { epInfo.development = true; } @@ -204,6 +198,7 @@ class SkillInfo { class EpisodeInfo { String name; String gametype; + String header; String description; bool extended; bool development; diff --git a/resources/assets/zscript/lib/lemonutil.zs b/resources/assets/zscript/lib/lemonutil.zs index bd9fe6f..971f4fa 100644 --- a/resources/assets/zscript/lib/lemonutil.zs +++ b/resources/assets/zscript/lib/lemonutil.zs @@ -34,6 +34,21 @@ class LemonUtil { }; return classes[id]; } + static int ClassNameToSimple(string className) { + Array simple = { + "corvus", + "fighter", + "cleric", + "mage", + "paladin", + "cleric", + "necromancer", + "assassin", + "succubus", + "corvus" + }; + return simple.Find(className); + } static void LaunchMap(String mapId, int skill) { LemonUtil.CVAR_SetString("hxdd_map_select", String.format("%s,%d", mapId, skill)); @@ -105,6 +120,19 @@ class LemonUtil { return -1; } + static int GetGameType(String type) { + String gametype = type.MakeLower(); + if (gametype == "heretic") { + return 1; + } else if (gametype == "hexen") { + return 2; + } else if (gametype == "doom") { + return 3; + } else { + return 0; + } + } + static int GetOptionGameMode() { int cvarGameMode = LemonUtil.CVAR_GetInt("hxdd_gamemode", 0); int gameType = gameinfo.gametype; diff --git a/resources/assets/zscript/menu/newgame.zs b/resources/assets/zscript/menu/newgame.zs index 537f683..a03a784 100644 --- a/resources/assets/zscript/menu/newgame.zs +++ b/resources/assets/zscript/menu/newgame.zs @@ -33,6 +33,10 @@ class ZFPreGameSetupHandler : HXDD_ZF_Handler { } else if (menu.frame.getPosX() == -1920) { // start game with selected settings Menu.MenuSound("menu/choose"); + if (menu.selectedGameMode == 0) { + EpisodeInfo episode = menu.frameGameOptions.gameinfo.episodes[menu.selectedEpisode]; + menu.selectedGameMode = LemonUtil.GetGameType(episode.gametype); + } LemonUtil.CVAR_SetInt("hxdd_gamemode", menu.selectedGameMode); LemonUtil.CVAR_SetInt("hxdd_armor_mode", menu.selectedArmorMode); LemonUtil.CVAR_SetInt("hxdd_progression", menu.selectedProgressionMode); @@ -118,12 +122,17 @@ class ZFGameOptionsHandler : HXDD_ZF_Handler { } void ShowEpisodeInformation() { - if (menu.selectedEpisode < 6) { - optMenu.SetInfoText("$MNU_HEADER_HERETIC", "$MNU_STORY_HERETIC"); - } else if (menu.selectedEpisode == 6) { - optMenu.SetInfoText("$MNU_HEADER_HEXEN", "$MNU_STORY_HEXEN"); - } else if (menu.selectedEpisode == 7) { - optMenu.SetInfoText("$MNU_HEADER_HEXDD", "$MNU_STORY_HEXDD"); + if (optMenu.gameinfo.episodes.Size() - 1 < menu.selectedEpisode) { + optMenu.SetInfoText("ERROR!", "THIS EPISODE IS OUT OF RANGE AND MAY CRASH UPON STARTING!\nCHECK YOUR WADS AND PK3 FILES!"); + return; + } + EpisodeInfo episode = optMenu.gameinfo.episodes[menu.selectedEpisode]; + if (episode.description != "") { + String header = episode.header; + if (header == "") { + header = episode.name; + } + optMenu.SetInfoText(header, episode.description); } else { optMenu.SetInfoText("$MNU_HEADER_OTHER", "$MNU_STORY_OTHER"); }