Skip to content

Commit

Permalink
Fix FaceWidget description position after ui.sameLine is used
Browse files Browse the repository at this point in the history
Adjust mission description to mockup
  • Loading branch information
vakhoir committed Feb 27, 2020
1 parent 05f4007 commit 1f13f7f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
8 changes: 4 additions & 4 deletions data/libs/ui/PiguiFace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ function PiGuiFace.New (character, style)
end

function PiGuiFace:render ()
local startPos = ui.getCursorPos()
ui.image(self.texture.id, self.style.size, Vector2(0.0, 0.0), self.texture.uv, colors.white)

if(self.style.showCharInfo) then
local lastPos = ui.getCursorPos()
ui.setCursorPos(lastPos - Vector2(0.0, self.style.charInfoHeight + self.style.itemSpacing.y))
local endPos = ui.getCursorPos()
ui.setCursorPos(startPos - Vector2(0.0, self.style.charInfoHeight - self.style.size.y))
ui.withStyleColorsAndVars({ChildWindowBg = self.style.charInfoBgColor}, {WindowPadding = self.style.charInfoPadding, ItemSpacing = self.style.itemSpacing}, function ()
ui.child("PlayerInfoDetails", Vector2(self.style.size.x, self.style.charInfoHeight), charInfoFlags, function ()
ui.withFont(self.style.nameFont.name, self.style.nameFont.size, function()
Expand All @@ -78,7 +78,7 @@ function PiGuiFace:render ()
end
end)
end)
ui.setCursorPos(lastPos)
ui.setCursorPos(endPos)
end
end

Expand Down
10 changes: 10 additions & 0 deletions data/modules/DeliverPackage/DeliverPackage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ local onChat = function (form, ref, option)
flavour = ad.flavour,
description = ad.desc,
icon = ad.urgency >= 0.8 and "delivery_urgent" or "delivery",
introtext = string.interp(flavours[ad.flavour].introtext, {
name = ad.client.name,
cash = Format.Money(ad.reward,false),
starport = ad.location:GetSystemBody().name,
system = ad.location:GetStarSystem().name,
sectorx = ad.location.sectorX,
sectory = ad.location.sectorY,
sectorz = ad.location.sectorZ,
dist = string.format("%.2f", ad.dist),
})
}

table.insert(missions,Mission.New(mission))
Expand Down
43 changes: 36 additions & 7 deletions data/pigui/modules/info-view/04-missions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ local missionDetailsBg = Color(12, 29, 52)

local vZero = Vector2(0,0)
local adTextColor = colors.white
local searchFlags = ui.WindowFlags {}
local containerFlags = ui.WindowFlags {"AlwaysUseWindowPadding"}
local entryFlags = ui.WindowFlags {"AlwaysUseWindowPadding", "AlwaysAutoResize"}
local listFlags = ui.WindowFlags {}
local detailsFlags = ui.WindowFlags {"AlwaysUseWindowPadding", "AlwaysAutoResize"}
local widgetSizes = ui.rescaleUI({
iconSize = Vector2(20, 20),
chatButtonBase = Vector2(0, 24),
chatButtonSize = Vector2(0, 24),
itemSpacing = Vector2(18, 4),
bbContainerSize = Vector2(0, 0),
bbSearchSize = Vector2(0, 0),
bbPadding = Vector2(14, 11),
bbPadding = Vector2(12, 12),
innerPadding = Vector2(0, 3),
popupSize = Vector2(1200, 0),
popupBig = Vector2(1200, 0),
popupSmall = Vector2(500, 0),
faceSize = Vector2(280, 320),
missionDesc = {
-- distLength = ui.calcTextSize(string.format('%.2f %s', 99999, l.LY))
distLength = 150,
Expand Down Expand Up @@ -79,6 +80,8 @@ local jobList = List.New("JobList", false, {
if self.itemsMeta[key] ~= nil and self.itemsMeta[key].min and self.itemsMeta[key].max then
if self.highlightedItem == key then
ui.addRectFilled(self.itemsMeta[key].min, self.itemsMeta[key].max, self.style.highlightColor, 0, 0)
elseif selectedItem == item then
ui.addRectFilled(self.itemsMeta[key].min, self.itemsMeta[key].max, missionDetailsBg, 0, 0)
else
ui.addRectFilled(self.itemsMeta[key].min, self.itemsMeta[key].max, Color(8, 19, 40), 0, 0)
end
Expand Down Expand Up @@ -127,7 +130,14 @@ local jobList = List.New("JobList", false, {
end

selectedItem = item
clientFace = InfoFace.New(item.client, {windowPadding = widgetSizes.windowPadding, itemSpacing = widgetSizes.itemSpacing, size = widgetSizes.faceSize})
clientFace = InfoFace.New(item.client, {
windowPadding = widgetSizes.windowPadding,
itemSpacing = widgetSizes.itemSpacing,
size = widgetSizes.faceSize,
charInfoPadding = Vector2(12,12),
nameFont = orbiteer.large,
titleFont = orbiteer.medlarge,
})
end,
sortingFunction = function(s1,s2) return s1.description < s2.description end
})
Expand Down Expand Up @@ -167,7 +177,7 @@ local function renderView()
--print("start", scrollPos)
scrollPos = ui.vSliderInt('###MissionsScrollbar', Vector2(10, ui.getContentRegion().y), scrollPosPrev, -100, 0, "")
ui.sameLine()
ui.child("MissionList", Vector2(ui.screenWidth * 0.5, 0), searchFlags, function()
ui.child("MissionList", Vector2(ui.screenWidth * 0.5, 0), listFlags, function()
ui.text("Filter")
ui.sameLine()
ui.text("Sort:")
Expand All @@ -187,8 +197,27 @@ local function renderView()

if selectedItem then
ui.sameLine()
ui.withStyleColorsAndVars({ChildWindowBg = missionDetailsBg},{WindowPadding = widgetSizes.bbPadding}, function()
ui.child("MissionDetails", vZero, searchFlags, function()
ui.withStyleColorsAndVars({ChildWindowBg = missionDetailsBg},{WindowPadding = Vector2(8, 16)}, function()
ui.child("MissionDetails", vZero, detailsFlags, function()
local winSize = ui.getContentRegion() - widgetSizes.faceSize
ui.columns(2, "MissionDetailsColumns", false)
ui.setColumnWidth(0, winSize.x)
ui.setColumnWidth(1, widgetSizes.faceSize.x)
ui.withFont(orbiteer.xlarge.name, orbiteer.xlarge.size, function()
ui.text(string.upper(selectedItem:GetTypeDescription()))
end)
ui.text('')

ui.pushTextWrapPos(winSize.x*0.8)
ui.textWrapped(selectedItem.introtext)
ui.popTextWrapPos()

ui.text('')
ui.text(string.format('Destination: %s, %s', selectedItem.location:GetSystemBody().name, selectedItem.location:GetStarSystem().name))
ui.text(string.format('Deadline: %s', Format.Date(selectedItem.due)))
ui.text(string.format('Wage: %s', Format.Money(selectedItem.reward)))

ui.nextColumn()
clientFace:render()
end)
end)
Expand Down

0 comments on commit 1f13f7f

Please sign in to comment.