Browse Source

Fixed MenuDialog Lua Bug #565

master
Christopher 8 years ago
parent
commit
eabbed3e7a
  1. 33
      Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt
  2. 20
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaUtils.cs
  3. 2186
      Assets/Tests/Lua/FungusTests.unity

33
Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt vendored

@ -137,7 +137,6 @@ end
-- Options for configuring Say Dialog behaviour
M.sayoptions = {}
M.sayoptions.saydialog = nil
M.sayoptions.clearprevious = true
M.sayoptions.waitforinput = true
M.sayoptions.fadewhendone = true
@ -145,17 +144,12 @@ M.sayoptions.stopvoiceover = true
-- Set the active saydialog to use with the say and conversation functions
function M.setsaydialog(saydialog)
M.sayoptions.saydialog = saydialog
luautils.SetSayDialog(saydialog)
end
-- Gets the active say dialog, or creates one if none exists yet
-- Gets the active say dialog
function M.getsaydialog()
if (M.sayoptions.saydialog == nil) then
local sd = M.luautils.spawn("Prefabs/SayDialog").GetComponent("SayDialog")
M.setsaydialog(sd)
end
return M.sayoptions.saydialog
return M.luautils.GetSayDialog()
end
-- Set the active character on the Say Dialog
@ -168,17 +162,17 @@ function M.setcharacter(character, portrait)
-- Do substitution on character name
local subbed = M.sub(character.nameText)
M.sayoptions.saydialog.SetCharacterName(subbed, character.nameColor)
M.getsaydialog().SetCharacterName(subbed, character.nameColor)
-- Try to set the portrait sprite
if (portrait) then
if (portrait == "") then
M.sayoptions.saydialog.SetCharacterImage(nill)
M.getsaydialog().SetCharacterImage(nill)
else
for i,v in ipairs(character.portraits) do
-- Use a case insensitive comparison
if (string.lower(v.name) == string.lower(portrait)) then
M.sayoptions.saydialog.SetCharacterImage(v)
M.getsaydialog().SetCharacterImage(v)
end
end
end
@ -214,22 +208,14 @@ end
-- Menu Dialog
--------------
-- Options for configuring Menu Dialog behaviour
M.menuoptions = {}
-- Set the active menudialog to use with the menu function
function M.setmenudialog(menudialog)
M.menuoptions.menudialog = menudialog
luautils.SetMenuDialog(menudialog)
luautils.SetMenuDialog(menudialog)
end
-- Gets the active menu dialog, or creates one if none exists yet
-- Gets the active menu dialog
function M.getmenudialog()
if (M.menuoptions.menudialog == nil) then
local md = M.luautils.spawn("Prefabs/MenuDialog").GetComponent("MenuDialog")
M.setmenudialog(md)
end
return M.menuoptions.menudialog
return M.luautils.GetMenuDialog()
end
-- Display a menu button
@ -324,8 +310,7 @@ end
-- Clear all currently displayed menu options
function M.clearmenu()
assert(M.menuoptions.menudialog, "menudialog must not be nil")
M.menuoptions.menudialog.Clear()
M.getmenudialog().Clear()
end
------------

20
Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaUtils.cs vendored

@ -459,18 +459,32 @@ namespace Fungus
/// <summary>
/// Sync the active say dialog with what Lua thinks the SayDialog should be
/// </summary>
public void SetSayDialog(SayDialog sayDialog)
public virtual void SetSayDialog(SayDialog sayDialog)
{
SayDialog.ActiveSayDialog = sayDialog;
}
/// <summary>
/// Returns the current say dialog.
/// </summary>
public virtual SayDialog GetSayDialog ()
{
return SayDialog.GetSayDialog();
}
/// <summary>
/// Sync the active menu dialog with what Lua thinks the MenuDialog should be
/// Sync the active menu dialog with what Lua things the MenuDialog should be
/// </summary>
public void SetMenuDialog(MenuDialog menuDialog)
public virtual void SetMenuDialog(MenuDialog menuDialog)
{
MenuDialog.ActiveMenuDialog = menuDialog;
}
/// <summary>
/// Returns the current menu dialog
/// </summary>
public virtual MenuDialog GetMenuDialog()
{
return MenuDialog.GetMenuDialog();
}
#endregion

2186
Assets/Tests/Lua/FungusTests.unity

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save