diff --git a/data/libs/SpaceStation.lua b/data/libs/SpaceStation.lua index 0fcf3b22bb..66b3030ebe 100644 --- a/data/libs/SpaceStation.lua +++ b/data/libs/SpaceStation.lua @@ -576,11 +576,12 @@ local function addRandomShipAdvert(station, num) local def = avail[Engine.rand:Integer(1,#avail)] local model = Engine.GetModel(def.modelName) local pattern = model.numPatterns ~= 0 and Engine.rand:Integer(1,model.numPatterns) or nil + local label = Ship.MakeRandomLabel() addShipOnSale(station, { def = def, - skin = ModelSkin.New():SetRandomColors(Engine.rand):SetDecal(def.manufacturer), + skin = ModelSkin.New():SetRandomColors(Engine.rand):SetDecal(def.manufacturer):SetLabel(label), pattern = pattern, - label = Ship.MakeRandomLabel(), + label = label, }) end end diff --git a/data/modules/SearchRescue/SearchRescue.lua b/data/modules/SearchRescue/SearchRescue.lua index 0d8f27fae4..039f257ae1 100644 --- a/data/modules/SearchRescue/SearchRescue.lua +++ b/data/modules/SearchRescue/SearchRescue.lua @@ -711,9 +711,9 @@ local createTargetShip = function (mission) end -- set ship looks (label, skin, pattern) - ship:SetLabel(mission.shiplabel) local skin = ModelSkin.New():SetRandomColors(rand):SetDecal(shipdef.manufacturer) ship:SetSkin(skin) + ship:SetLabel(mission.shiplabel) local model = Engine.GetModel(shipdef.modelName) local pattern if model.numPatterns <= 1 then diff --git a/data/pigui/modules/new-game-window/class.lua b/data/pigui/modules/new-game-window/class.lua index 64ec53db22..565fb60180 100644 --- a/data/pigui/modules/new-game-window/class.lua +++ b/data/pigui/modules/new-game-window/class.lua @@ -125,6 +125,7 @@ local function startGame(gameParams) local skin = ModelSkin.New() skin:SetColors({ primary = colors[1], secondary = colors[2], trim = colors[3] }) skin:SetDecal(shipDef.manufacturer) + skin:SetLabel(gameParams.ship.label) player:SetSkin(skin) -- setup player character diff --git a/data/pigui/modules/new-game-window/crew.lua b/data/pigui/modules/new-game-window/crew.lua index 4499ddb6f7..e9c1a8c4d3 100644 --- a/data/pigui/modules/new-game-window/crew.lua +++ b/data/pigui/modules/new-game-window/crew.lua @@ -325,7 +325,7 @@ function Crew:drawMember(memberEntry) Widgets.verticalCenter(self.layout, function() Widgets.alignLabel(lui.NAME_PERSON, self.layout, function() local txt, changed = Widgets.inputText(lock, memberEntry:isValid(), "##charname" .. tostring(memberEntry), tostring(memberEntry.value.name), function() - memberEntry.value.name = NameGen.FullName(memberEntry.value.female) + return NameGen.FullName(memberEntry.value.female) end) if changed then memberEntry.value.name = txt diff --git a/data/pigui/modules/new-game-window/ship.lua b/data/pigui/modules/new-game-window/ship.lua index 71c128ffe5..778bfb1259 100644 --- a/data/pigui/modules/new-game-window/ship.lua +++ b/data/pigui/modules/new-game-window/ship.lua @@ -99,7 +99,7 @@ ShipName.layout = {} function ShipName:draw() Widgets.alignLabel(lui.SHIP_NAME, self.layout, function() local txt, changed = Widgets.inputText(self.lock, self:isValid(), "##shipname", self.value, function() - self.value = ShipNames.generateRandom() + return ShipNames.generateRandom() end) if changed then self.value = txt end end) @@ -135,9 +135,12 @@ ShipLabel.value = "" function ShipLabel:draw() Widgets.oneLiner(lui.REGISTRATION_NUMBER, self.layout, function() local txt, changed = Widgets.inputText(self.lock, self:isValid(), "##ShipLabel", self.value, function() - self.value = ShipObject.MakeRandomLabel() + return ShipObject.MakeRandomLabel() end) - if changed then self.value = txt end + if changed then + self.value = txt + ShipModel:updateModel() + end end) end @@ -218,6 +221,7 @@ function ShipModel:updateModel() if not self.skin then return end local c = self.value.colors self.skin:SetColors({ primary = c[1], secondary = c[2], trim = c[3] }) + self.skin:SetLabel(ShipLabel.value) self.spinner:setModel(modelName, self.skin, self.value.pattern) end diff --git a/data/pigui/modules/new-game-window/widgets.lua b/data/pigui/modules/new-game-window/widgets.lua index 4dafc6a35c..f13a250709 100644 --- a/data/pigui/modules/new-game-window/widgets.lua +++ b/data/pigui/modules/new-game-window/widgets.lua @@ -109,7 +109,10 @@ Widgets.inputText = function(lock, valid, id, text, randomFnc) local txt, changed = ui.inputText(id, text) ui.sameLine() if ui.iconButton(ui.theme.icons.random, Vector2(size, size), tostring(id) .. "_random_button") then - randomFnc() + local newtxt = randomFnc() + if newtxt and newtxt ~= txt then + txt, changed = newtxt, true + end end return txt, changed else diff --git a/data/pigui/modules/station-view/06-shipRepairs.lua b/data/pigui/modules/station-view/06-shipRepairs.lua index 1cc87e29c1..10f3802d27 100644 --- a/data/pigui/modules/station-view/06-shipRepairs.lua +++ b/data/pigui/modules/station-view/06-shipRepairs.lua @@ -141,7 +141,7 @@ local function changeColor() local player = Game.player local shipDef = ShipDef[player.shipId] local newColor = reformatColor(previewColors) - previewSkin = ModelSkin.New():SetColors(newColor):SetDecal(shipDef.manufacturer) + previewSkin = ModelSkin.New():SetColors(newColor):SetDecal(shipDef.manufacturer):SetLabel(player.label) refreshModelSpinner() end diff --git a/src/scenegraph/Label3D.cpp b/src/scenegraph/Label3D.cpp index 00244018c4..3af8d9092f 100644 --- a/src/scenegraph/Label3D.cpp +++ b/src/scenegraph/Label3D.cpp @@ -52,6 +52,8 @@ namespace SceneGraph { { //regenerate geometry m_geometry->Clear(); + m_textMesh.reset(); + if (!text.empty()) { m_font->GetGeometry(*m_geometry, text, vector2f(0.f));