We did. Josh actually dug through the internals of that exact library quite thoroughly at my recommendation. As this is foremost a debug UI I was able to keep it quite minimal and the implementation time was rather short. Doing it from scratch also helps us understand some of the features and API we want from our ideal, real UI. When we get to that point we'll have to reevaluate whether to use a library, roll our own, or extend what I've already built. One of the concerns Josh had with it was our ability to make it look nice. And I'd be lying if I said that 'not-invented-here syndrome' didn't play a small part. Not that we'd forgo pragmatism, but knowing a system inside and out and having complete control of it often leads to a better end product. Especially with the amount of attention to detail currently occupying this office space.Haron wrote: ↑Mon Oct 02, 2017 3:04 pmHi Adam. It was interesting to read you update for me as a developer. Great work! Hope to see new updates from you and Josh.
After reading your post I'm wondering if you and Josh discussed a possibility to use some existing UI libraries (i.e. ImGui is being used in the several game engines as dev UI) before starting to implement your own?
In this mostly-toy example, the biggest things are 1) removing the hasInput parameter and check and 2) moving the input handling to a UI widget that overlays the GameView.Grumblesaur wrote: ↑Mon Oct 02, 2017 3:59 pmThanks for the mini-update, Adam. You showed us what the old code used to look like with that Lua function -- what would be the equivalent structure with the refactor?
In the code snippet the left click functionality is related to the ship the player is controlling while the target selection is actually related to developer controls that aren't intended to be part of gameplay. This paradigm makes that difference explicit because the input checks end up in different control widgets.
So what started as
Code: Select all
-- Ship.lua
function Ship.Create ()
-- <stuff>
end
function Ship.free ()
-- <stuff>
end
function onUpdate (dt, hasFocus)
if hasFocus then
if PHX.Mouse.Pressed(PHX.MouseButton.Left) then
self:fire()
end
if PHX.Mouse.Pressed(PHX.MouseButton.Right) then
self.camera:setTarget(self:getPick())
end
end
end
Code: Select all
-- Ship.lua
function Ship.Create ()
-- <stuff>
end
function Ship.free ()
-- <stuff>
end
Code: Select all
-- ShipController.lua
function onInput ()
if PHX.Mouse.Pressed(PHX.MouseButton.Left) then
self.ship:fire()
end
end
Code: Select all
-- DebugPicker.lua
function onInput ()
if PHX.Mouse.Pressed(PHX.MouseButton.Right) then
self.camera:setTarget(self:getPick())
end
end