Skip to content

Commit

Permalink
Added an option to re-generate the custom hero name in the custom her…
Browse files Browse the repository at this point in the history
…o creation menu
  • Loading branch information
Andrettin committed Apr 1, 2017
1 parent 52f8a83 commit a345ae0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 15 additions & 6 deletions scripts/menus/custom_hero.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a345ae0

Please sign in to comment.