From 9283a74a22af1e426d2739aa9ffb66ba674c9c38 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 15 Sep 2014 16:59:12 +0200 Subject: [PATCH] Fix r2ed --HG-- branch : develop --- code/ryzom/client/src/far_tp.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 1 + .../r2/r2_core_user_component_manager.lua | 2 +- code/ryzom/common/data_common/r2/r2_debug.lua | 3 +- code/ryzom/common/data_common/r2/r2_logic.lua | 2 +- code/ryzom/common/data_common/r2/r2_misc.lua | 14 ++- .../common/data_common/r2/r2_ui_forms.lua | 2 +- .../data_common/r2/r2_ui_property_sheet.lua | 92 +++++++++---------- .../data_common/r2/unit_test/r2_unit_test.lua | 12 +-- 9 files changed, 71 insertions(+), 59 deletions(-) diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index 2fb3f0c37..4f48d2ff5 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -1132,7 +1132,7 @@ void CFarTP::disconnectFromPreviousShard() */ NetMngr.reinit(); - if (isIngame()) + if (isIngame() && !isReselectingChar()) { nlinfo("FarTP: calling EntitiesMngr.reinit()"); EntitiesMngr.reinit(); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index fe4c6a716..996bd698a 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1931,6 +1931,7 @@ void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg) #endif pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); } + nldebug("LUA: '%s'", dbg.c_str()); } diff --git a/code/ryzom/common/data_common/r2/r2_core_user_component_manager.lua b/code/ryzom/common/data_common/r2/r2_core_user_component_manager.lua index 6769d503b..4aa445484 100644 --- a/code/ryzom/common/data_common/r2/r2_core_user_component_manager.lua +++ b/code/ryzom/common/data_common/r2/r2_core_user_component_manager.lua @@ -1116,7 +1116,7 @@ function userComponentManager:export(list, refX, refY, refZ) messageBox(i18n.get("uiR2EDInvalidName")) return end - if string.find(form.ComponentFileName, '\.lua', -4) == nil then + if string.find(form.ComponentFileName, '.lua', -4) == nil then form.ComponentFileName = form.ComponentFileName .. ".lua" end local refPosition = form.RefPosition diff --git a/code/ryzom/common/data_common/r2/r2_debug.lua b/code/ryzom/common/data_common/r2/r2_debug.lua index 6a63b5472..78501dcab 100644 --- a/code/ryzom/common/data_common/r2/r2_debug.lua +++ b/code/ryzom/common/data_common/r2/r2_debug.lua @@ -140,7 +140,8 @@ end function assert(cond) if not cond then - rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ") + -- rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ") + rawDebugInfo("@{FOFF}ASSERTION FAILED !! ") dumpCallStack(2); error("") end diff --git a/code/ryzom/common/data_common/r2/r2_logic.lua b/code/ryzom/common/data_common/r2/r2_logic.lua index 1ee35d562..d50a15faf 100644 --- a/code/ryzom/common/data_common/r2/r2_logic.lua +++ b/code/ryzom/common/data_common/r2/r2_logic.lua @@ -1679,7 +1679,7 @@ Logic.translateChatSequences = function (context, hlComponent, behavior, rtNpcGr event.Name = "activity_sequence_changed" table.insert(context.RtAct.Events, event) - local rtInitChatStep = r2.Translator.createAction("code", "oldChatStepVar = -1;\n" .. Logic.chatStepVar .." = 0;\n()setTimer(1, " ..Logic.chatTimerId .. ")\;\n") + local rtInitChatStep = r2.Translator.createAction("code", "oldChatStepVar = -1;\n" .. Logic.chatStepVar .." = 0;\n()setTimer(1, " ..Logic.chatTimerId .. ");\n") rtInitChatStep.Name = "init_chat_step" table.insert(context.RtAct.Actions, rtInitChatStep) table.insert(event.ActionsId, rtInitChatStep.Id) diff --git a/code/ryzom/common/data_common/r2/r2_misc.lua b/code/ryzom/common/data_common/r2/r2_misc.lua index ee9e2885e..f3c9fa865 100644 --- a/code/ryzom/common/data_common/r2/r2_misc.lua +++ b/code/ryzom/common/data_common/r2/r2_misc.lua @@ -32,9 +32,8 @@ end -- extension to table library : remove all content of a table without deleting the table object function table.clear(tbl) while next(tbl) do - tbl[next(tbl)] = nil + table.remove(tbl, next(tbl)) end - table.setn(tbl, 0) end ------------------------------------------------------------------------------------------------------------ @@ -174,6 +173,17 @@ end function strify(str) return [["]] .. tostring(str) .. [["]] end + +------------------------------------------------------------------------------------------------- +-- enclose a string by double quotes +function strifyXml(str) + strxml = string.gsub(str, ">", ">") + strxml = string.gsub(strxml, "<", "<") + strxml = string.gsub(strxml, "&", "&") + strxml = string.gsub(strxml, "'", "'") + strxml = string.gsub(strxml, '"', """) + return [["]] .. tostring(strxml) .. [["]] +end ------------------------------------------------------------------------------------------------------------ -- snap a position to ground, returning the z snapped coordinate diff --git a/code/ryzom/common/data_common/r2/r2_ui_forms.lua b/code/ryzom/common/data_common/r2/r2_ui_forms.lua index ae1b4d656..587581f26 100644 --- a/code/ryzom/common/data_common/r2/r2_ui_forms.lua +++ b/code/ryzom/common/data_common/r2/r2_ui_forms.lua @@ -328,7 +328,7 @@ end local function saveScenarioOnChange(formInstance) r2.print(formInstance.Name) - local name = string.gsub(formInstance.Name, "[\\\/\:\*\?\"\<\>\|]", "_") + local name = string.gsub(formInstance.Name, "[\\/:*?\"<>|]", "_") if name ~= formInstance.Name then fromInstance.Name = name formInstance.Modified = true diff --git a/code/ryzom/common/data_common/r2/r2_ui_property_sheet.lua b/code/ryzom/common/data_common/r2/r2_ui_property_sheet.lua index 962eaf315..e4fbd4632 100644 --- a/code/ryzom/common/data_common/r2/r2_ui_property_sheet.lua +++ b/code/ryzom/common/data_common/r2/r2_ui_property_sheet.lua @@ -47,13 +47,13 @@ function r2:buildEditBox(prop, textRef, entryType, multiLine, maxNumChars, onCha bg_texture="grey_40.tga" onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()" onenter="lua" on_focus_lost="lua"]] .. - [[ id= ]] .. strify(prop.Name) .. - [[ text_ref = ]] .. strify(textRef) .. - [[ entry_type = ]] .. strify(entryType) .. - [[ multi_line = ]] .. strify(multiLine) .. - [[ max_num_chars = ]] .. strify(maxNumChars) .. - [[ params = ]] .. strify(onChangeAction) .. - [[ on_focus_lost_params = ]] .. strify(onFocusLostAction) .. + [[ id= ]] .. strifyXml(prop.Name) .. + [[ text_ref = ]] .. strifyXml(textRef) .. + [[ entry_type = ]] .. strifyXml(entryType) .. + [[ multi_line = ]] .. strifyXml(multiLine) .. + [[ max_num_chars = ]] .. strifyXml(maxNumChars) .. + [[ params = ]] .. strifyXml(onChangeAction) .. + [[ on_focus_lost_params = ]] .. strifyXml(onFocusLostAction) .. "/>" return result end @@ -73,13 +73,13 @@ end -- bg_texture="grey_40.tga" -- onchange="lua" onchange_params="getUICaller():setupDisplayText(); getUICaller():find('edit_text'):updateCoords(); getUICaller():getEnclosingContainer().Env.updateSize()" -- onenter="lua" on_focus_lost="lua"]] .. --- [[ id= ]] .. strify(prop.Name) .. --- [[ text_ref = ]] .. strify(textRef) .. --- [[ entry_type = ]] .. strify(entryType) .. --- [[ multi_line = ]] .. strify(multiLine) .. --- [[ max_num_chars = ]] .. strify(maxNumChars) .. --- [[ params = ]] .. strify(onChangeAction) .. --- [[ on_focus_lost_params = ]] .. strify(onChangeAction) .. +-- [[ id= ]] .. strifyXml(prop.Name) .. +-- [[ text_ref = ]] .. strifyXml(textRef) .. +-- [[ entry_type = ]] .. strifyXml(entryType) .. +-- [[ multi_line = ]] .. strifyXml(multiLine) .. +-- [[ max_num_chars = ]] .. strifyXml(maxNumChars) .. +-- [[ params = ]] .. strifyXml(onChangeAction) .. +-- [[ on_focus_lost_params = ]] .. strifyXml(onChangeAction) .. -- [[ /> -- -- @@ -1043,7 +1043,7 @@ r2.WidgetStyles.Number = width1 = tmp end - local part0 = [[ ]] + local part0 = [[ ]] local tooltipTextId, tooltipTextIdFound = buildPropTooltipName(className, prop.Name) @@ -1051,7 +1051,7 @@ r2.WidgetStyles.Number = tooltip_parent="win" tooltip_posref="auto" instant_help="true" - tooltip=]] .. strify(tooltipTextId) .. ">" + tooltip=]] .. strifyXml(tooltipTextId) .. ">" part0 = part0 .. buildCoverAllButton(prop) local color = "255 255 255 255" @@ -1066,10 +1066,10 @@ r2.WidgetStyles.Number = end part0 = part0 .. [[ ]] + [[ id = ]] .. strifyXml(prop.Name .. "_Caption") .. + [[ hardtext = ]] .. strifyXml(hardText) .. + [[ color = ]] .. strifyXml(color) .. + [[ global_color=]] .. strifyXml(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]] part0 = part0 .. "" part0 = part0 .. "" @@ -1086,7 +1086,7 @@ r2.WidgetStyles.Number = -- local widgetXml = string.format([[ - " .. [[ + " .. [[ " result = result .. [[]] -- append enumerated values for k, v in pairs(prop.Enum) do - result = result .. [[]] + result = result .. [[]] end result = result .. "" return result, setter @@ -1201,10 +1201,10 @@ function r2:createPropertyXmlTable(props, className, posparent, posref, x, y, wi result = result .. value end add([[ ]] + part0 = [[ ]] part0 = part0 .. [[" + tooltip=]] .. strifyXml(tooltipTextId) .. ">" part0 = part0 .. [[ ]] + [[ id = ]] .. strifyXml(prop.Name .. "_Caption") .. + [[ hardtext = ]] .. strifyXml(hardText) .. + [[ color = ]] .. strifyXml(color) .. + [[ global_color=]] .. strifyXml(globalColor) .. [[ fontsize="12" shadow="true" auto_clamp="true"/> ]] part0 = part0 .. "" part0 = part0 .. "" else @@ -1268,13 +1268,13 @@ function r2:createPropertyXmlTable(props, className, posparent, posref, x, y, wi end -- build the widget - local part1 = [[ ]] + local part1 = [[ ]] part1 = part1 .. [[" + tooltip=]] .. strifyXml(tooltipTextId) .. ">" part1 = part1 .. widgetXmlDesc .. [[]] if invertWidget then @@ -1397,15 +1397,15 @@ function r2:buildPropRolloutXml(caption, id, posparent, posref, props, className -- add the rollout bar if not isForm then result = result .. - [[ ]] else result = result .. - [[ ]] end @@ -1475,9 +1475,9 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm) if isForm then -- for forms, closing the form is equivalent to clicking on 'cancel' add(' resizer="true" ') local w = defaulting(class.Width, 500) - add(' pop_min_w=' .. strify(w)) - add(' pop_max_w=' .. strify(w)) - add(' w=' .. strify(w)) + add(' pop_min_w=' .. strifyXml(w)) + add(' pop_max_w=' .. strifyXml(w)) + add(' w=' .. strifyXml(w)) local cancelCode = [[ local form = getUICaller() if form.Env.Choice == nil then @@ -1518,7 +1518,7 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm) - add([[id=]] .. strify(id) .. [[ + add([[id=]] .. strifyXml(id) .. [[ >]]) @@ -1647,7 +1647,7 @@ function r2:buildPropertySheetXml(class, className, id, title, isForm) - + ]]) diff --git a/code/ryzom/common/data_common/r2/unit_test/r2_unit_test.lua b/code/ryzom/common/data_common/r2/unit_test/r2_unit_test.lua index 572f2080a..b48e3da5a 100644 --- a/code/ryzom/common/data_common/r2/unit_test/r2_unit_test.lua +++ b/code/ryzom/common/data_common/r2/unit_test/r2_unit_test.lua @@ -36,7 +36,7 @@ UnitTest.testLoadAnimationScenarioUi = function() end local filename = form.LoadScenario_Name - if string.find(filename, '\.r2', -3) == nil then + if string.find(filename, '.r2', -3) == nil then local ui = r2:getForm("LoadScenario") ui.active = true @@ -134,12 +134,12 @@ UnitTest.testLoadScenarioUi = function() local ucName = ucstring() ucName:fromUtf8(form.LoadScenario_Name) local filename = tostring(ucName) - if string.find(filename, '\.r2', -3) == nil then + if string.find(filename, '.r2', -3) == nil then messageBox(i18n.get("uiR2EDLoadScenario_InvalidFileName")) return end --- if string.find(filename, '\.r2', -3) == nil then +-- if string.find(filename, '.r2', -3) == nil then -- filename = form.Name .. ".r2" -- end @@ -206,7 +206,7 @@ function UnitTest.saveScenario(name, overwrite) messageBox(i18n.get("uiR2EDInvalidName")) return end - if string.find(name, '\.r2', -3) == nil then + if string.find(name, '.r2', -3) == nil then name = name .. ".r2" end -- update scenario name with the new name @@ -1103,8 +1103,8 @@ end function t5() - local toto = "&ezr_חא'_\\)d //:1' 2 יייא'..)א\/:*?\"<>|א)@4 58ftgsfdg\"\/:*?\"<>|" - toto = string.gsub(toto, "[\\\/\:\*\?\"\<\>\|]", "_") + local toto = "&ezr_חא'_\\)d //:1' 2 יייא'..)א/:*?\"<>|א)@4 58ftgsfdg\"/:*?\"<>|" + toto = string.gsub(toto, "[\\/:*?\"<>|]", "_") end