-
Notifications
You must be signed in to change notification settings - Fork 236
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
Annotate some of the functionality related to worldviews #6600
base: develop
Are you sure you want to change the base?
Changes from all commits
b32c8da
0529957
c7a5f5f
b21373c
f80dca0
92fcf1f
8294306
839855b
8d6b947
2d6845b
ed55f9f
4c43841
15e6b7c
0a61a3b
e40c1bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- (#6600) Annotate functionality related to worldviews |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,67 @@ | ||
--***************************************************************************** | ||
--* File: lua/modules/ui/game/gamemain.lua | ||
--* Author: Chris Blackwell | ||
--* Summary: Entry point for the in game UI | ||
--* | ||
--* Copyright � 2005 Gas Powered Games, Inc. All rights reserved. | ||
--***************************************************************************** | ||
--****************************************************************************************************** | ||
--** Copyright (c) 2022 Willem 'Jip' Wijnia | ||
--** | ||
--** Permission is hereby granted, free of charge, to any person obtaining a copy | ||
--** of this software and associated documentation files (the "Software"), to deal | ||
--** in the Software without restriction, including without limitation the rights | ||
--** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
--** copies of the Software, and to permit persons to whom the Software is | ||
--** furnished to do so, subject to the following conditions: | ||
--** | ||
--** The above copyright notice and this permission notice shall be included in all | ||
--** copies or substantial portions of the Software. | ||
--** | ||
--** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
--** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
--** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
--** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
--** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
--** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
--** SOFTWARE. | ||
--****************************************************************************************************** | ||
|
||
--- This module is responsible for creating the secondary worldview. | ||
--- | ||
--- This module is tightly coupled with the following module(s): | ||
--- - lua/ui/game/worldview.lua | ||
|
||
local UIUtil = import("/lua/ui/uiutil.lua") | ||
local LayoutHelpers = import("/lua/maui/layouthelpers.lua") | ||
local Group = import("/lua/maui/group.lua").Group | ||
local GameCommon = import("/lua/ui/game/gamecommon.lua") | ||
local Bitmap = import("/lua/maui/bitmap.lua").Bitmap | ||
|
||
---@type WorldView | false | ||
view = false | ||
|
||
--- Shows the logo in the secondary adapter. | ||
function ShowLogoInHead1() | ||
if GetNumRootFrames() < 2 then return end | ||
|
||
--------------------------------------------------------------------------- | ||
-- defensive programming | ||
|
||
-- don't do anything if there's only one root frame | ||
if GetNumRootFrames() < 2 then | ||
return | ||
end | ||
|
||
local rootFrame = GetFrame(1) | ||
local bg = Bitmap(rootFrame, UIUtil.UIFile('/marketing/splash.dds')) | ||
LayoutHelpers.FillParentPreserveAspectRatio(bg, rootFrame) | ||
end | ||
|
||
--- Creates a world view on the secondary adapter. The worldview is registered and available in the world view manager. | ||
--- | ||
--- This function is referenced directly by the engine. | ||
function CreateSecondView() | ||
if GetNumRootFrames() < 2 then return end | ||
|
||
|
||
--------------------------------------------------------------------------- | ||
-- defensive programming | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
|
||
-- don't do anything if there's only one root frame | ||
if GetNumRootFrames() < 2 then | ||
return | ||
end | ||
|
||
ClearFrame(1) | ||
secondHeadGroup = Group(GetFrame(1), "secondHeadGroup") | ||
LayoutHelpers.FillParent(secondHeadGroup, GetFrame(1)) | ||
|
@@ -33,5 +70,8 @@ function CreateSecondView() | |
view:Register('CameraHead2', nil, '<LOC map_view_0003>Secondary View', 3) | ||
view:SetRenderPass(UIUtil.UIRP_UnderWorld | UIUtil.UIRP_PostGlow) -- don't change this or the camera will lag one frame behind | ||
LayoutHelpers.FillParent(view, secondHeadGroup) | ||
end | ||
|
||
end | ||
-- backwards compatibility for mods | ||
|
||
local GameCommon = import("/lua/ui/game/gamecommon.lua") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,39 @@ | |
--* Copyright © 2005 Gas Powered Games, Inc. All rights reserved. | ||
--***************************************************************************** | ||
|
||
--- This module is responsible for creating the primary worldview(s) and managing all worldviews in general. | ||
--- | ||
--- This module is tightly coupled with the following module(s): | ||
--- - lua/ui/game/multihead.lua | ||
|
||
local UIUtil = import("/lua/ui/uiutil.lua") | ||
local LayoutHelpers = import("/lua/maui/layouthelpers.lua") | ||
local Bitmap = import("/lua/maui/bitmap.lua").Bitmap | ||
local Group = import("/lua/maui/group.lua").Group | ||
local Factions = import("/lua/factions.lua").Factions | ||
|
||
---@type { [string]: WorldView } | ||
--- A list of all available worldviews. | ||
---@type table<string, WorldView> | ||
MapControls = {} | ||
|
||
--- A group that covers the entire screen. | ||
---@type Group | false | ||
view = false | ||
|
||
--- Primary view, and if in split screen this is the left view. The left view is always visible. | ||
--- | ||
--- Most features that rely on a worldview only work for the left worldview. One example is the reclaim overlay. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a lua implementation detail, I don't think it is necessary in the documentation, as it is absolutely possible to have multi-view UI elements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is, but it's an intentional choice that we do not. For example, the reclaim overlay would be too expensive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good to document it as a ton of UI Lua being coupled to this specific worldview, but I think what stands out to me with this specific comment is that "features that rely on a worldview only work for the left worldview" sounds as if the engine depends on |
||
---@type WorldView | false | ||
viewLeft = false | ||
|
||
--- Secondary view used in split screen. This is the right view. | ||
---@type WorldView | false | ||
viewRight = false | ||
|
||
secondaryView = false | ||
|
||
tertiaryView = false | ||
|
||
local parentForFrame = false | ||
|
||
positionMarkers = {} | ||
|
@@ -131,6 +150,10 @@ function MarkStartPositions(startPositions) | |
end | ||
end | ||
|
||
--- Creates the world view on the primary monitor. | ||
---@param parent Control | ||
---@param mapGroup Control | ||
---@param mapGroupRight? Control # if provided, creates a split view with a separate world view in both map groups | ||
function CreateMainWorldView(parent, mapGroup, mapGroupRight) | ||
-- feature: preserve the world camera when changing views | ||
---@type UserCamera | ||
|
@@ -298,9 +321,10 @@ function UnlockInput() | |
end | ||
end | ||
|
||
-- this function is called by the engine so it can not be removed (its logic could be changed though) | ||
--- This function is called by the engine so it cannot be removed (its logic could be changed though) | ||
---@return boolean | ||
function IsInputLocked() | ||
return (viewLeft and viewLeft:IsInputLocked()) or (viewRight and viewRight:IsInputLocked()) | ||
return (viewLeft and viewLeft:IsInputLocked()) or (viewRight and viewRight:IsInputLocked()) or false | ||
end | ||
|
||
function ForwardMouseWheelInput(event) | ||
|
@@ -311,6 +335,7 @@ function ForwardMouseWheelInput(event) | |
end | ||
end | ||
|
||
---@param val boolean | ||
function SetHighlightEnabled(val) | ||
if viewLeft then | ||
viewLeft:SetHighlightEnabled(val) | ||
|
@@ -345,7 +370,7 @@ function UnregisterWorldView(view) | |
end | ||
end | ||
|
||
---@return { [string]: WorldView } | ||
---@return table<string, WorldView> | ||
function GetWorldViews() | ||
return MapControls | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cluttering comments.