diff --git a/readme.txt b/readme.txt index a4b451a529..1a15928d0b 100644 --- a/readme.txt +++ b/readme.txt @@ -72,6 +72,7 @@ https://github.com/Andrettin/Wyrmsun * Heroes - Fixed issue which allowed Germanic worker heroes to build Germanic buildings even if controlled by another civilization. +- Added an option to re-generate the custom hero name in the custom hero creation menu. * Items - Fixed issue which allowed items to be used or dropped from the unit's main command panel if there were no button there, and its inventory also had an item button at that same spot. diff --git a/scripts/menus/custom_hero.lua b/scripts/menus/custom_hero.lua index e28f566ce7..7396a7fbcf 100644 --- a/scripts/menus/custom_hero.lua +++ b/scripts/menus/custom_hero.lua @@ -60,6 +60,14 @@ function CustomHeroCreationMenu(world, quest_menu) local variation local language + + local function GenerateNewHeroName() + local generated_personal_name = "" + while (generated_personal_name == "" or GetArrayIncludes(GetCustomHeroes(), generated_personal_name)) do + generated_personal_name = GeneratePersonalName(hero_class_ident_list[hero_class:getSelected() + 1]) + end + hero_name:setText(generated_personal_name) + end local function ClassChanged() trait_ident_list = nil @@ -93,11 +101,7 @@ function CustomHeroCreationMenu(world, quest_menu) if (new_language ~= language) then -- if the language changed, generate a new name for the hero language = new_language - local generated_personal_name = "" - while (generated_personal_name == "" or GetArrayIncludes(GetCustomHeroes(), generated_personal_name)) do - generated_personal_name = GeneratePersonalName(hero_class_ident_list[hero_class:getSelected() + 1]) - end - hero_name:setText(generated_personal_name) + GenerateNewHeroName() end end @@ -159,7 +163,7 @@ function CustomHeroCreationMenu(world, quest_menu) hero_civilization:setSelected(0) CivilizationChanged() - menu:addFullButton("Create ~!Hero", "h", 176 - (224 / 2), 352 - 40 * 2, + menu:addHalfButton("Crea~!te", "t", 20 + 48, 352 - 40 * 2, function() local hero_ident = hero_name:getText() if (hero_family_name:getText() ~= "") then @@ -194,6 +198,11 @@ function CustomHeroCreationMenu(world, quest_menu) end end ) + menu:addHalfButton("New ~!Name", "n", 130 + 48, 352 - 40 * 2, + function() + GenerateNewHeroName() + end + ) menu:addFullButton("~!Cancel", "c", 176 - (224 / 2), 352 - 40 * 1, function() menu:stop()