Skip to content
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

WorldviewCommandModeTableStreamline #6585

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

clyfordv
Copy link
Contributor

  • Modifies controls/worldview.lua to call GetCommandMode once and store as a local table.
  • Modifies commandmode.lua to only update the commandModeTable (what's returned by GetCommandMode) when the command mode changes.
  • Minor: removes an unecessary check for the alt attack move cursor that didn't respect preferences.

Copy link
Contributor

@lL1l1 lL1l1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally it makes sense.
It is possible to dirty the command mode table and then that would get used by other UI elements looking for the command mode, but that was already possible before (get table -> change table -> yield -> someone else gets the table and resets your changes) without issues so I don't think it'll become a problem. Perhaps a simple warning that the table shouldn't be modified would be suitable?

@@ -635,7 +633,7 @@ WorldView = ClassUI(moho.UIWorldView, Control) {
local cursor = self.Cursor
cursor[1], cursor[2], cursor[3], cursor[4], cursor[5] = UIUtil.GetCursor(identifier)
self:ApplyCursor()
CommandMode.GetCommandMode()[2].reticle = TeleportReticle(self)
commandModeTable[2].reticle = TeleportReticle(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels wrong to stuff data into the commad mode data that is UI related. Imagine if this is a script command with a reticle and we pass unserializable userdata inside a table: the game would immediately crash (as I discovered when annotating script tasks, and I doubt that LuaParams gets passed with any other orders, as it is logically not necessary).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that line can just be taken out; originally I had the idea that the command mode table was a good vehicle for different UI elements to get access to the reticle (or anything) but it doesn't apply in this case.

(believe I said this before)

@lL1l1 lL1l1 added the area: ui Anything to do with the User Interface of the Game label Dec 22, 2024
@lL1l1 lL1l1 added this to the Development I of 2025 milestone Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ui Anything to do with the User Interface of the Game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants