-
Notifications
You must be signed in to change notification settings - Fork 84
Role distribution inspection #1714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 68 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
5d63312
Tighten up padding in F1 menu submenu list
nike4613 c0c48fc
Move role-related administrative panels into Roles top-level tab
nike4613 5e27cd5
Add a proper message when search yields no results
nike4613 bcb4604
Add roles overview page in UI
nike4613 c6c0f1d
Re-add administration submenu files to override the Workshop files
nike4613 5d4ea01
Insert prints to debug rolelayering sync
nike4613 26d362f
Fix role layering menu
nike4613 c978a5b
Tweak debug prints
nike4613 d1fb33e
Revert "Insert prints to debug rolelayering sync"
nike4613 03a4b3d
Finish role overview document
nike4613 180c984
Update role layering description to be more descriptive.
nike4613 23db47a
stylua
nike4613 3e80013
Changelog
nike4613 a29c74e
glualint
nike4613 bf96018
Document DSubmenuListTTT2:ResetSubmenuList()
nike4613 787e076
Add the infra for role decision inspection
nike4613 7c4a9d3
Instrument GetAllSelectableRolesList with role inspection
nike4613 6acbd82
Instrument GetSelectableRolesList
nike4613 36e0f05
Try out putting highlight on search bar above text
nike4613 e38641a
Report subrole selection order in GetSelectableRolesList
nike4613 66b2f45
Instrument baserole, subrole, and final role selection
nike4613 21cb2be
Fix ReportDecision call in SelectBaseRolePlayers
nike4613 8659385
Begin implementing UI for role distribution inspection
nike4613 28f3cf5
Adjust roleinspect UI to be slightly more easy to work with
nike4613 642883b
Add skeleton for final 3 roleinspect stages
nike4613 900a1ee
Render role layers for STAGE_LAYERING
nike4613 9ea91b1
Add language strings for the first 2 stages of the roleinspect GUI
nike4613 33a452d
Add subrole upgrade order UI
nike4613 7d3ca56
Implement baserole assignment stage UI
nike4613 9584776
Collapse all roleinspect sections by default
nike4613 1b342b1
Render baserole distribution correctly when derandomization is disabled
nike4613 0eda1c5
Implement UI for subrole upgrades and final roles
nike4613 e6997a2
stylua
nike4613 9a7c826
glualint
nike4613 3199223
changelog
nike4613 590faf8
Add sort mode player name to DPlayerGraph
nike4613 d8d60f2
splling
nike4613 90168e1
Merge remote-tracking branch 'upstream/master' into role-scrutability
nike4613 24f4b78
Merge remote-tracking branch 'upstream/master' into gui
nike4613 a3eaa40
Merge branch 'gui' into role-scrutability
nike4613 d9fc055
neodoc
nike4613 f68949e
Make sure the UI doesn't fail when no subroles are present
nike4613 a6dcbe9
Tweak some help messages to be a bit more clear
nike4613 c86b063
Fix empty roleinspect info message
nike4613 10fb438
stylua
nike4613 44f16e1
Merge remote-tracking branch 'upstream/master' into role-scrutability
nike4613 9c12b6a
Remove duplicate GetVisibleNonSearchedSubmenus
nike4613 6b94ba3
Merge remote-tracking branch 'upstream/master' into role-scrutability
nike4613 714f735
toggle role indicator
TimGoll 2c919a5
fixed doc string
TimGoll c19cb75
Merge branch 'toggle-role-check-indicator' of github.com:TTT-2/TTT2 i…
nike4613 b1e8d2d
Merge branch 'toggle-role-check-indicator' of github.com:TTT-2/TTT2 i…
nike4613 62081c0
also hide the outline
TimGoll 3e167fc
Merge branch 'toggle-role-check-indicator' of github.com:TTT-2/TTT2 i…
nike4613 905f3a3
remove outline offset when no outline
TimGoll 06da787
Merge branch 'toggle-role-check-indicator' of github.com:TTT-2/TTT2 i…
nike4613 76d8dcf
Adjust for new DRoleImage changes
nike4613 5828433
Darken roles which aren't considered because they're not selectable a…
nike4613 b721225
Update gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua
TimGoll 0f58faa
Merge branch 'toggle-role-check-indicator' of github.com:TTT-2/TTT2 i…
nike4613 a3d9aff
Merge remote-tracking branch 'upstream/master' into role-scrutability
nike4613 12484ef
Add translation string for ROLEINSPECT_REASON_NO_DECISION
nike4613 f7f97d7
Merge branch 'master' into role-scrutability
TimGoll 0993284
Use existing text wrapping code
nike4613 326ed93
Remove commented out prints
nike4613 1c40987
Move roleinspect to libraries folder
nike4613 efd9d5b
Remove some unused bits
nike4613 614e95b
Address more feedback
nike4613 8883a25
Add an extra help box to unknown layer sroleinspect
nike4613 bdd7080
stylua
nike4613 2df44ec
bruh
nike4613 4419fbc
Update gamemodes/terrortown/gamemode/server/sv_roleselection.lua
nike4613 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
241 changes: 241 additions & 0 deletions
241
gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dpippanel_ttt2.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,241 @@ | ||
| --- | ||
| -- @class PANEL | ||
| -- @section DPiPPanelTTT2 | ||
|
|
||
| local PANEL = {} | ||
|
|
||
| --- | ||
| -- @accessor string | ||
| -- @realm client | ||
| AccessorFunc(PANEL, "Padding", "Padding", FORCE_NUMBER) | ||
| --- | ||
| -- @accessor number | ||
| -- @realm client | ||
| AccessorFunc(PANEL, "innerPadding", "InnerPadding", FORCE_NUMBER) | ||
| --- | ||
| -- @accessor number | ||
| -- @realm client | ||
| AccessorFunc(PANEL, "pipOuterOffset", "OuterOffset", FORCE_NUMBER) | ||
|
|
||
| --- | ||
| -- @ignore | ||
| function PANEL:Init() | ||
| self:SetPadding(0) | ||
| self:SetInnerPadding(2) | ||
| self:SetOuterOffset(0) | ||
|
|
||
| self.mainPanel = nil | ||
| self.subPanels = {} | ||
| end | ||
|
|
||
| --- | ||
| -- Adds a child panel. The first such panel is the "main" panel, and appears larger than the others. All others are positioned over the main, according to their alignment. | ||
| -- @param Panel|string|table pnl The panel to add. If it is an actual panel, added directly. Otherwise, the name/table of a panel to create. | ||
| -- @param DOCK ... Alignment. Only LEFT, RIGHT, TOP, and BOTTOM are valid. The first specified direction specifies the preferred axis (the axis along which it will be moved to prevent overlap). | ||
| -- @return The added panel. | ||
| -- @realm client | ||
| function PANEL:Add(pnl, ...) | ||
| local realPnl | ||
| if ispanel(pnl) then | ||
| realPnl = pnl | ||
| pnl:SetParent(self) | ||
| elseif istable(pnl) then | ||
| realPnl = vgui.CreateFromTable(pnl, self) | ||
| else | ||
| realPnl = vgui.Create(pnl, self) | ||
| end | ||
|
|
||
| if self.mainPanel == nil then | ||
| -- the first panel added becomes the main panel | ||
| self.mainPanel = realPnl | ||
| self:InvalidateLayout() | ||
| return realPnl | ||
| end | ||
|
|
||
| -- later panels become sub-panels | ||
| self.subPanels[#self.subPanels + 1] = { | ||
| pnl = realPnl, | ||
| align = { ... }, | ||
| } | ||
|
|
||
| self:InvalidateLayout() | ||
| self:InvalidateChildren() | ||
|
|
||
| return realPnl | ||
| end | ||
|
|
||
| --- | ||
| -- Clears this panel. | ||
| -- @realm client | ||
| function PANEL:Clear() | ||
| if self.mainPanel then | ||
| self.mainPanel:Remove() | ||
| self.mainPanel = nil | ||
| end | ||
| for _, pnl in pairs(self.subPanels) do | ||
| pnl.pnl:Remove() | ||
| end | ||
| self.subPanels = {} | ||
| end | ||
|
|
||
| local function RectsOverlap(r1, r2) | ||
| local x11, y11 = r1.x, r1.y | ||
| local x12, y12 = r1.x + r1.w, r1.y + r1.h | ||
| local x21, y21 = r2.x, r2.y | ||
| local x22, y22 = r2.x + r2.w, r2.y + r2.h | ||
|
|
||
| -- take the max/min coords, if width or height is negative there is no overlap | ||
| local xn1 = math.max(x11, x21) | ||
| local yn1 = math.max(y11, y21) | ||
| local xn2 = math.min(x12, x22) | ||
| local yn2 = math.min(y12, y22) | ||
|
|
||
| -- note that exact edge meets are considered overlaps for this | ||
| return xn2 >= xn1 and yn2 >= yn1 | ||
| end | ||
|
|
||
| local axisX = 1 | ||
| local axisY = 2 | ||
| local axisCoordTbl = { | ||
| [axisX] = "x", | ||
| [axisY] = "y", | ||
| } | ||
| local axisSizeTbl = { | ||
| [axisX] = "w", | ||
| [axisY] = "h", | ||
| } | ||
|
|
||
| --- | ||
| -- @ignore | ||
| function PANEL:PerformLayout() | ||
| local mainPanel = self.mainPanel | ||
| if not IsValid(mainPanel) then | ||
| -- no main panel, nothing to actually layout | ||
| return | ||
| end | ||
|
|
||
| local mw, mh = mainPanel:GetSize() | ||
| local padding = self:GetPadding() | ||
| local innerPadding = self:GetInnerPadding() | ||
| local outerOffset = self:GetOuterOffset() | ||
|
|
||
| -- we can't immediately set our own size or the main panel's position because we | ||
| -- need to look at the sub-panels first | ||
| local leftBound = -padding | ||
| local rightBound = mw + padding | ||
| local topBound = -padding | ||
| local bottomBound = mh + padding | ||
|
|
||
| -- subpanel positions relative to the TL corner of the main panel | ||
| -- stores panel->hitbox index | ||
| -- need this because we need to go through the subpanels to determine where the | ||
| -- main panel will go | ||
| local subPnlRelPos = {} | ||
| local subPnlHitboxes = {} | ||
|
|
||
| for i, pnl in ipairs(self.subPanels) do | ||
| -- align center is 0, 0; -1 = left/top, +1 = right/bottom | ||
| local alignx, aligny = 0, 0 | ||
|
|
||
| local preferAxis = 0 -- the preferred direction; the first one provided | ||
|
|
||
| if istable(pnl.align) then | ||
| -- loop through the alignments to identify it | ||
| for _, align in ipairs(pnl.align) do | ||
| local axis = 0 | ||
| if align == TOP then | ||
| axis = axisY | ||
| aligny = -1 | ||
| elseif align == BOTTOM then | ||
| axis = axisY | ||
| aligny = 1 | ||
| elseif align == LEFT then | ||
| axis = axisX | ||
| alignx = -1 | ||
| elseif align == RIGHT then | ||
| axis = axisX | ||
| alignx = 1 | ||
| end | ||
|
|
||
| if axis ~= 0 and preferAxis == 0 then | ||
| preferAxis = axis | ||
| end | ||
| end | ||
| end | ||
|
|
||
| -- if no alignment axis was specified, use the X axis | ||
| if preferAxis == 0 then | ||
| preferAxis = axisX | ||
| end | ||
|
|
||
| -- we now have a usable understanding of the alignment request | ||
|
|
||
| -- time to figure out where to put the subpanel | ||
| local pw, ph = pnl.pnl:GetSize() | ||
|
|
||
| -- start with the preferred position | ||
| -- outermost corner/edge | ||
| local outerx = (mw / 2) + alignx * (mw / 2) | ||
| local outery = (mh / 2) + aligny * (mh / 2) | ||
| -- then adjust because we need the top-left corner always | ||
| local x = outerx - ((alignx + 1) * (pw / 2)) | ||
| local y = outery - ((aligny + 1) * (ph / 2)) | ||
| -- then adjust according to the outerOffset | ||
| x = x + alignx * outerOffset | ||
| y = y + aligny * outerOffset | ||
|
|
||
| local rect = { x = x, y = y, w = pw, h = ph } | ||
|
|
||
| -- now that we've used the alignment properly, make sure the axes are nonzero | ||
| -- so that our preferred axis move actually moves it | ||
| if alignx == 0 then | ||
| alignx = -1 | ||
| end | ||
| if aligny == 0 then | ||
| aligny = -1 | ||
| end | ||
|
|
||
| local paxisCoord = axisCoordTbl[preferAxis] | ||
| local paxisSize = axisSizeTbl[preferAxis] | ||
| local paxisAlign = preferAxis == axisX and alignx or aligny | ||
|
|
||
| -- now that we have our target rectangle, check for intersections against all | ||
| -- existing rectangles and adjust along the preferred axis to not overlap | ||
| for j = 1, #subPnlHitboxes do | ||
| local box = subPnlHitboxes[j] | ||
|
|
||
| if RectsOverlap(rect, box) then | ||
| -- overlap, move rect to be non-overlapping along the target axis | ||
|
|
||
| -- to do so, we first set the relevant axis to the box | ||
| rect[paxisCoord] = box[paxisCoord] | ||
|
|
||
| -- then, we adjust position by the width accodring to the align value | ||
| rect[paxisCoord] = rect[paxisCoord] | ||
| + -paxisAlign * ((paxisAlign < 0 and box or rect)[paxisSize] + innerPadding) | ||
| end | ||
| end | ||
|
|
||
| -- we now have a good position for this item, update the bounds | ||
| leftBound = math.min(leftBound, rect.x) | ||
| rightBound = math.max(rightBound, rect.x + rect.w) | ||
| topBound = math.min(topBound, rect.y) | ||
| bottomBound = math.max(bottomBound, rect.y + rect.h) | ||
|
|
||
| -- and add the box and panel entry | ||
| subPnlHitboxes[#subPnlHitboxes + 1] = rect | ||
| subPnlRelPos[pnl.pnl] = #subPnlHitboxes | ||
| end | ||
|
|
||
| -- we now know how to position and size everything, so do that | ||
| local mainx, mainy = -leftBound, -topBound | ||
| self:SetSize(rightBound - leftBound, bottomBound - topBound) | ||
| mainPanel:SetPos(mainx, mainy) | ||
|
|
||
| for pnl, recti in pairs(subPnlRelPos) do | ||
| local rect = subPnlHitboxes[recti] | ||
| pnl:SetPos(mainx + rect.x, mainy + rect.y) | ||
| end | ||
| end | ||
|
|
||
| derma.DefineControl("DPiPPanelTTT2", "A panel-in-panel panel.", PANEL, "DPanelTTT2") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.