Skip to content

Commit

Permalink
Merge pull request #5842 from Web-eWorks/fix-missing-label
Browse files Browse the repository at this point in the history
Fix lots of missing ship labels
  • Loading branch information
Webster Sheets authored Jun 26, 2024
2 parents 2a00314 + d38f8ea commit 935a3a5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
5 changes: 3 additions & 2 deletions data/libs/SpaceStation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/modules/SearchRescue/SearchRescue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions data/pigui/modules/new-game-window/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/pigui/modules/new-game-window/crew.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions data/pigui/modules/new-game-window/ship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

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

Expand Down
5 changes: 4 additions & 1 deletion data/pigui/modules/new-game-window/widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/pigui/modules/station-view/06-shipRepairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/scenegraph/Label3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 935a3a5

Please sign in to comment.