diff --git a/CHANGELOG.md b/CHANGELOG.md index fcdf299..c868560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +1.3.0 + --Every UI now utilizes delayed server/client communication + Will help tremendously with any high ping issues. + This will also cause a 1-5 sec delay when activating Movement of the UI's + --Added PVPSector, will show if a sector has pvp damaged Enabled/Disabled. + --ScrapyardLicenses now has the option to Allow for Clicking to show the sector on the map. + --ScrapyardLicenses now has the option to show both alliance/player licenses at the same time. + --CargoNotifier now has the option to have the UI Flash + --ObjectDetector now has the option to have the UI Flash + +1.2.1 + -Fixed Entity Creation bug error. + 1.2.0 -Added ObjectDetector Special Thxs to dnightmare, we were apprently working on this at the same time. diff --git a/PVPSector.jpg b/PVPSector.jpg new file mode 100644 index 0000000..fdd9a12 Binary files /dev/null and b/PVPSector.jpg differ diff --git a/README.md b/README.md index 2ee4cbd..dc446db 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ He and I infact started work on this together, but he beat me to it. So I took his work and incorperated my work in to his. Thxs again!! +## PVPSector +This UI will display when you are inside a Player Enabled/Disabled Sector. + +![alt text](https://imgur.com/S4SPW7R.png) + Remember with all these UI's they can be Moved, Enabled, Disabled, or even restricted to specific situations (coding skill required) ![alt text](https://imgur.com/oy5WRlG.png) @@ -86,6 +91,8 @@ I encourage all modders to adopt this file structure as default, as its likely t ## Downloads ___ +https://github.com/dirtyredz/MoveUI/releases/download/1.3.0/MoveUI.v1.3.0.zip + https://github.com/dirtyredz/MoveUI/releases/download/1.2.1/MoveUI.v1.2.1.zip https://github.com/dirtyredz/MoveUI/releases/download/1.2.0/MoveUI.v1.2.0.zip @@ -97,6 +104,16 @@ https://github.com/dirtyredz/MoveUI/releases/download/1.0.0/MoveUI.v1.0.0.zip ## Changelog ___ +1.3.0 + --Every UI now utilizes delayed server/client communication + Will help tremendously with any high ping issues. + This will also cause a 1-5 sec delay when activating Movement of the UI's + --Added PVPSector, will show if a sector has pvp damaged Enabled/Disabled. + --ScrapyardLicenses now has the option to Allow for Clicking to show the sector on the map. + --ScrapyardLicenses now has the option to show both alliance/player licenses at the same time. + --CargoNotifier now has the option to have the UI Flash + --ObjectDetector now has the option to have the UI Flash + 1.2.1 -Fixed Entity Creation bug error. diff --git a/README.txt b/README.txt index c539398..20a93a9 100644 --- a/README.txt +++ b/README.txt @@ -53,6 +53,12 @@ He and I infact started work on this together, but he beat me to it. So I took his work and incorperated my work in to his. Thxs again!! +[center][b][size=25pt]PVPSector[/size][/b][/center] +This UI will display when you are inside a Player Enabled/Disabled Sector. + +[img]http://imgur.com/S4SPW7R.png[/img] + + Remember with all these UI's they can be Moved, Enabled, Disabled, or even restricted to specific situations (coding skill required) [img]https://imgur.com/oy5WRlG.png[/img] @@ -85,10 +91,12 @@ I encourage all modders to adopt this file structure as default, as its likely t [b][size=24pt]Downloads[/size][/b] [hr] -[url=https://github.com/dirtyredz/MoveUI/releases/download/1.2.1/MoveUI.v1.2.1.zip]MoveUI v1.2.1[/url] +[url=https://github.com/dirtyredz/MoveUI/releases/download/1.3.0/MoveUI.v1.3.0.zip]MoveUI v1.3.0[/url] Older Downloads [spoiler] +[url=https://github.com/dirtyredz/MoveUI/releases/download/1.2.1/MoveUI.v1.2.1.zip]MoveUI v1.2.1[/url] + [url=https://github.com/dirtyredz/MoveUI/releases/download/1.2.0/MoveUI.v1.2.0.zip]MoveUI v1.2.0[/url] [url=https://github.com/dirtyredz/MoveUI/releases/download/1.1.0/MoveUI.v1.1.0.zip]MoveUI v1.1.0[/url] @@ -98,6 +106,16 @@ Older Downloads [b][size=24pt]Changelog[/size][/b] [hr] +1.3.0 + --Every UI now utilizes delayed server/client communication + Will help tremendously with any high ping issues. + This will also cause a 1-5 sec delay when activating Movement of the UI's + --Added PVPSector, will show if a sector has pvp damaged Enabled/Disabled. + --ScrapyardLicenses now has the option to Allow for Clicking to show the sector on the map. + --ScrapyardLicenses now has the option to show both alliance/player licenses at the same time. + --CargoNotifier now has the option to have the UI Flash + --ObjectDetector now has the option to have the UI Flash + 1.2.1 -Fixed Entity Creation bug error. diff --git a/mods/MoveUI/config/MoveUIConfig.lua b/mods/MoveUI/config/MoveUIConfig.lua index d2a69ec..9769556 100644 --- a/mods/MoveUI/config/MoveUIConfig.lua +++ b/mods/MoveUI/config/MoveUIConfig.lua @@ -1,6 +1,6 @@ local MoveUIConfig = {} - -MoveUIConfig.version = "[1.2.0]" +MoveUIConfig.Author = "Dirtyredz" +MoveUIConfig.version = "[1.3.0]" MoveUIConfig.ModName = "[MoveUI]" MoveUIConfig.HudList = {} @@ -23,5 +23,6 @@ MoveUIConfig.AddUI("DistCore") MoveUIConfig.AddUI("CargoNotifier", true) MoveUIConfig.AddUI("ScrapyardLicenses", true) MoveUIConfig.AddUI("ObjectDetector", true) +MoveUIConfig.AddUI("PVPSector", true) return MoveUIConfig diff --git a/mods/MoveUI/scripts/lib/MoveUI.lua b/mods/MoveUI/scripts/lib/MoveUI.lua index 586a9a2..78ddf7b 100644 --- a/mods/MoveUI/scripts/lib/MoveUI.lua +++ b/mods/MoveUI/scripts/lib/MoveUI.lua @@ -3,40 +3,39 @@ require('mods.MoveUI.scripts.lib.serialize') MoveUI.Serialize = serialize -function MoveUI.Enabled(player,rect,overide) - local AllowMoving = MoveUI.AllowedMoving(player) - if AllowMoving then - drawBorder(rect, ColorRGB(0.8,0.8,0.8)) +function MoveUI.Enabled(rect,overide) + drawBorder(rect, ColorRGB(0.8,0.8,0.8)) - local mouse = Mouse() - local Inside = false - if mouse.position.x < rect.upper.x and mouse.position.x > rect.lower.x then - if mouse.position.y < rect.upper.y and mouse.position.y > rect.lower.y then - Inside = true - end + local mouse = Mouse() + local Inside = false + if mouse.position.x < rect.upper.x and mouse.position.x > rect.lower.x then + if mouse.position.y < rect.upper.y and mouse.position.y > rect.lower.y then + Inside = true end + end - if Inside and mouse:mousePressed(1) then - return mouse.position, true - elseif overide then - return overide, false - end + if Inside and mouse:mousePressed(1) then + return mouse.position, true + elseif overide then + return overide, false end + return false, false end function MoveUI.AllowedMoving(player) if not player then return false end + return player:getValue('MoveUI') or false end function MoveUI.CheckOverride(player,default,override,title) if override then return override end - local OldOverride = Player():getValue(title..'_MUI') or 'return nil' + OldOverride = Player():getValue(title..'_MUI') or false - OldOverride = loadstring(OldOverride)() if OldOverride then + OldOverride = loadstring(OldOverride)() return vec2(OldOverride.x,OldOverride.y) end @@ -51,12 +50,14 @@ function MoveUI.GetOptions(player,title,defaults) end function MoveUI.SetOptions(player,title, options) + print('SetOptions') if onServer() then player:setValue(title..'_MUI_Opt', MoveUI.Serialize(options)) end end function MoveUI.AssignPlayerOverride(player,title,position) + print('AssignPlayerOverride') if onServer() then local NewPosition = {} NewPosition.x = position.x @@ -96,7 +97,7 @@ end function MoveUI.AllowClick(player,rect,func) local mouse = Mouse() local Inside = false - local AllowMoving = player:getValue('MoveUI') or false + local AllowMoving = MoveUI.AllowedMoving(player) if not AllowMoving then if mouse.position.x < rect.upper.x and mouse.position.x > rect.lower.x then if mouse.position.y < rect.upper.y and mouse.position.y > rect.lower.y then diff --git a/mods/MoveUI/scripts/player/CargoNotifier.lua b/mods/MoveUI/scripts/player/CargoNotifier.lua index fa722d9..9c3fc69 100644 --- a/mods/MoveUI/scripts/player/CargoNotifier.lua +++ b/mods/MoveUI/scripts/player/CargoNotifier.lua @@ -14,9 +14,32 @@ local DefaultOptions = { AF = false } local AF_OnOff +local rect +local res +local DefaulPosition +local LoadedOptions +local player +local Cargos +local AllowMoving function CargoNotifier.initialize(Description) - Player():registerCallback("onPreRenderHud", "onPreRenderHud") + if onClient() then + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") + + rect = Rect(vec2(),vec2(170,150)) + res = getResolution(); + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.34,res.y * 0.07) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) + + LoadedOptions = MoveUI.GetOptions(player,Title,DefaultOptions) + + local PlayerShip = player.craft + if not PlayerShip then return end + Cargos = PlayerShip:getCargos() + end end function CargoNotifier.buildTab(tabbedWindow) @@ -41,6 +64,7 @@ function CargoNotifier.buildTab(tabbedWindow) --make sure variables are local to this file only AF_OnOff = container:createCheckBox(TextVSplit.right, "On / Off", 'onAllowFlashing') + AF_OnOff.tooltip = 'Will Flash when dangerous cargo is detected.' --Pass the name of the function, and the checkbox return {onAllowFlashing = AF_OnOff} @@ -62,26 +86,25 @@ end function CargoNotifier.onPreRenderHud() if onClient() then - local PlayerShip = Player().craft - if not PlayerShip then return end - local Cargos = PlayerShip:getCargos() + if not Cargos then return end + local SeenIllegal = false local SeenStolen = false local SeenDangerous = false local SeenSuspicious = false - local rect = Rect(vec2(),vec2(170,150)) - local res = getResolution(); - --MoveUI - Dirtyredz|David McClain - local DefaulPosition = vec2(res.x * 0.34,res.y * 0.07) - rect.position = MoveUI.CheckOverride(Player(),DefaulPosition,OverridePosition,Title) - - OverridePosition, Moving = MoveUI.Enabled(Player(), rect, OverridePosition) - if OverridePosition and not Moving then - invokeServerFunction('setNewPosition', OverridePosition) + if OverridePosition then + rect.position = OverridePosition end - if MoveUI.AllowedMoving(Player()) then + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end + + drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) return end @@ -90,7 +113,6 @@ function CargoNotifier.onPreRenderHud() local HSplit = UIHorizontalMultiSplitter(rect, 10, 10, 3) --Flashing Option - local LoadedOptions = MoveUI.GetOptions(Player(),Title,DefaultOptions) if os.time() % 2 == 0 and LoadedOptions.AF then return end for TradingGood,index in pairs(Cargos) do @@ -118,6 +140,18 @@ function CargoNotifier.onPreRenderHud() end end +function CargoNotifier.updateClient(timeStep) + LoadedOptions = MoveUI.GetOptions(player,Title,DefaultOptions) + local PlayerShip = player.craft + if not PlayerShip then return end + Cargos = PlayerShip:getCargos() + AllowMoving = MoveUI.AllowedMoving(player) +end + +function CargoNotifier.getUpdateInterval() + return 5 +end + function CargoNotifier.setNewPosition(Position) MoveUI.AssignPlayerOverride(Player(),Title,Position) end diff --git a/mods/MoveUI/scripts/player/DistCore.lua b/mods/MoveUI/scripts/player/DistCore.lua index 4eebe2e..063beb8 100644 --- a/mods/MoveUI/scripts/player/DistCore.lua +++ b/mods/MoveUI/scripts/player/DistCore.lua @@ -10,9 +10,30 @@ local OverridePosition local Title = 'DistCore' local Icon = "data/textures/icons/chart.png" local Description = "Displays Distance to the center of the galaxy (core)." +local rect +local res +local DefaulPosition +local distanceFromCenter = '' +local AllowMoving +local player function DistCore.initialize() - Player():registerCallback("onPreRenderHud", "onPreRenderHud") + if onClient() then + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") + + rect = Rect(vec2(),vec2(160,25)) + res = getResolution(); + + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.045,res.y * 0.25) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) + + DistCore.GetDistance() + end + + Player():registerCallback("onSectorEntered", "onSectorEntered") end function DistCore.buildTab(tabbedWindow) @@ -45,29 +66,52 @@ function MoveUIOptions.UpdateColor(slider) end]] function DistCore.onPreRenderHud() - local rect = Rect(vec2(),vec2(160,25)) - local res = getResolution(); - --MoveUI - Dirtyredz|David McClain - local DefaulPosition = vec2(res.x * 0.045,res.y * 0.25) - rect.position = MoveUI.CheckOverride(Player(),DefaulPosition,OverridePosition,Title) - - OverridePosition, Moving = MoveUI.Enabled(Player(), rect, OverridePosition) - if OverridePosition and not Moving then - invokeServerFunction('setNewPosition', OverridePosition) + if OverridePosition then + rect.position = OverridePosition end - if MoveUI.AllowedMoving(Player()) then + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end + + drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) return end - --MoveUI - Dirtyredz|David McClain - local lx, ly = Sector():getCoordinates() - local distanceFromCenter = math.floor(length(vec2(lx,ly))) drawTextRect('Dist to Core: '..distanceFromCenter, rect,0, 0,ColorRGB(0,1,0), 15, 0, 0, 0) end +function DistCore.onSectorEntered(playerIndex) + DistCore.GetDistance() +end + +function DistCore.GetDistance(Distance) + if onClient() then + if Distance then + distanceFromCenter = Distance + return + end + invokeServerFunction('GetDistance') + return + end + local lx, ly = Sector():getCoordinates() + distanceFromCenter = math.floor(length(vec2(lx,ly))) + invokeClientFunction(Player(callingPlayer),'GetDistance',distanceFromCenter) +end + +function DistCore.updateClient(timeStep) + AllowMoving = MoveUI.AllowedMoving(player) +end + +function DistCore.getUpdateInterval() + return 5 +end + function DistCore.setNewPosition(Position) MoveUI.AssignPlayerOverride(Player(),Title,Position) end diff --git a/mods/MoveUI/scripts/player/ExampleUI.lua b/mods/MoveUI/scripts/player/ExampleUI.lua deleted file mode 100644 index 0aacd46..0000000 --- a/mods/MoveUI/scripts/player/ExampleUI.lua +++ /dev/null @@ -1,85 +0,0 @@ ---MoveUI - Dirtyredz|David McClain -package.path = package.path .. ";mods/MoveUI/scripts/lib/?.lua" --Required -local MoveUI = require('MoveUI') --Required - --- namespace ExampleUI -ExampleUI = {} ---Its curcial that the namespace is unique to this file, I suggest keeping it the same name as the file name - -local OverridePosition --Needed so, we can move the UI - ---Its crucial the Title is unique to this file, a same title as another UI will break the storing of Moved UI's -local Title = 'ExampleUI' --Need so we can set overrided values to the player -local Icon = "data/textures/icons/chart.png" --Used by the buildTab function -local Description = "An exampleUI" --Used by the buildTab function - -function ExampleUI.initialize() --Required - --Register onPreRenderHud to the player so we can start displaying HUD's - Player():registerCallback("onPreRenderHud", "onPreRenderHud") -end - -function ExampleUI.buildTab(tabbedWindow) --Builds a tab inside of the main MoveUI interface - --If you dont want thier to be a tab simply remove everything inside this function - local FileTab = tabbedWindow:createTab("", Icon, Title) - local container = FileTab:createContainer(Rect(vec2(0, 0), FileTab.size)); - - --split it 50/50 - local mainSplit = UIHorizontalSplitter(Rect(vec2(0, 0), FileTab.size), 0, 0, 0.5) - - --Top Message - local TopHSplit = UIHorizontalSplitter(mainSplit.top, 0, 0, 0.3) - local TopMessage = container:createLabel(TopHSplit.top.lower + vec2(10,10), Title, 16) - TopMessage.centered = 1 - TopMessage.size = vec2(FileTab.size.x - 40, 20) - - local Description = container:createTextField(TopHSplit.bottom, Description) -end - - -function ExampleUI.onPreRenderHud() --Heres where we display the hud - local rect = Rect(vec2(),vec2(160,25)) --default size of the rect (width,hight) - local res = getResolution(); --So we can position it properly inside the clients screen - - --MoveUI - Dirtyredz|David McClain - local DefaulPosition = vec2(res.x * 0.5, res.y * 0.5) --The default position (* 0.5 = middle of the screen) - rect.position = MoveUI.CheckOverride(Player(),DefaulPosition,OverridePosition,Title) --Here we check if were getting an override( moving ) - - OverridePosition, Moving = MoveUI.Enabled(Player(), rect, OverridePosition) --Here we enable movement of the UI - if OverridePosition and not Moving then --Check if were done moving. - invokeServerFunction('setNewPosition', OverridePosition) --Send the new X,Y to the server to store in the players Data - end - - if MoveUI.AllowedMoving(Player()) then --If were moving - drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) --display the UI's title and return so we can clearly see each UI's Rect/Position - return - end - --MoveUI - Dirtyredz|David McClain - - --Here begins what you want to display. - --As long as you use the original (rect) you can build whatever you like here. - drawTextRect('Example UI', rect,0, 0,ColorRGB(0,1,0), 15, 0, 0, 0) - --[[ - Note: ColorRGB() uses floats ie - ColorRGB(1,1,1) = White - ColorRGB(0,0,0) = Black - ColorRGB(0.5,0.5,0.5) = gray - - function drawTextRect(string text, Rect rect, int horizontalAlignment, int verticalAlignment, Color color, int size, int bold, int italic, int style) - - text = The text that is to be rendered - rect = The rect that functions as boundaries for the text - horizontalAlignment = -1 to position the text at the left, 0 to center it horizontally, +1 to position the text at the right - verticalAlignment = -1 to position the text at the top, 0 to center it vertically, +1 to position the text at the bottom - color = The color of the text, as an int - size = The font size of the rendered text - bold = Use 1 if the text should be bold, 0 otherwise - itali =c Use 1 if the text should be italic, 0 otherwise - style = The style of the text, 0 is default style, 1 is shadowed, 2 is outlined - ]] -end - -function ExampleUI.setNewPosition(Position) --Sends new x,y to the server - MoveUI.AssignPlayerOverride(Player(),Title,Position) -end - -return ExampleUI --We return here for when use by the main MoveUI interface. diff --git a/mods/MoveUI/scripts/player/ObjectDetector.lua b/mods/MoveUI/scripts/player/ObjectDetector.lua index 5dcbb4c..300a317 100644 --- a/mods/MoveUI/scripts/player/ObjectDetector.lua +++ b/mods/MoveUI/scripts/player/ObjectDetector.lua @@ -20,12 +20,28 @@ local asteroids = 0 local wrecks = 0 local stashes = 0 local exodus = 0 +local rect +local res +local DefaulPosition +local LoadedOptions +local AllowMoving +local player function ObjectDetector.initialize() if onClient() then - Player():registerCallback("onPreRenderHud", "onPreRenderHud") + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") ObjectDetector.detect() + LoadedOptions = MoveUI.GetOptions(player,Title,DefaultOptions) + + rect = Rect(vec2(),vec2(320,20)) + res = getResolution(); + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.5,res.y * 0.90) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) end + Player():registerCallback("onSectorEntered", "onSectorEntered") end @@ -51,6 +67,7 @@ function ObjectDetector.buildTab(tabbedWindow) --make sure variables are local to this file only AF_OnOff = container:createCheckBox(TextVSplit.right, "On / Off", 'onAllowFlashing') + AF_OnOff.tooltip = 'Will Flash when an object is detected.' --Pass the name of the function, and the checkbox return {onAllowFlashing = AF_OnOff} @@ -72,29 +89,26 @@ end function ObjectDetector.onPreRenderHud() if onClient() then - local ship = Player().craft + local ship = player.craft if not ship then return end - local rect = Rect(vec2(),vec2(320,20)) - local res = getResolution(); + if OverridePosition then + rect.position = OverridePosition + end - --MoveUI - Dirtyredz|David McClain - local DefaulPosition = vec2(res.x * 0.5,res.y * 0.90) - rect.position = MoveUI.CheckOverride(Player(),DefaulPosition,OverridePosition,Title) + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end - OverridePosition, Moving = MoveUI.Enabled(Player(),rect,OverridePosition) - if OverridePosition and not Moving then - invokeServerFunction('setNewPosition',OverridePosition) - end - if MoveUI.AllowedMoving(Player()) then drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) return end - --MoveUI - Dirtyredz|David McClain --Flashing Option - local LoadedOptions = MoveUI.GetOptions(Player(),Title,DefaultOptions) if os.time() % 2 == 0 and LoadedOptions.AF then return end local VSplit = UIVerticalMultiSplitter(rect, 5, 5, 3) @@ -124,11 +138,13 @@ function ObjectDetector.onPreRenderHud() end function ObjectDetector.updateClient(timeStep) - timeout = timeout + timeStep - if timeout > 5 then - timeout = 0 - ObjectDetector.detect() - end + ObjectDetector.detect() + LoadedOptions = MoveUI.GetOptions(player,Title,DefaultOptions) + AllowMoving = MoveUI.AllowedMoving(player) +end + +function ObjectDetector.getUpdateInterval() + return 5 end function ObjectDetector.onSectorEntered(playerIndex) diff --git a/mods/MoveUI/scripts/player/PVPSector.lua b/mods/MoveUI/scripts/player/PVPSector.lua new file mode 100644 index 0000000..daa2a48 --- /dev/null +++ b/mods/MoveUI/scripts/player/PVPSector.lua @@ -0,0 +1,103 @@ +--MoveUI - Dirtyredz|David McClain +package.path = package.path .. ";mods/MoveUI/scripts/lib/?.lua" +local MoveUI = require('MoveUI') + +-- namespace PVPSector +PVPSector = {} + +local OverridePosition + +local Title = 'PVPSector' +local Icon = "data/textures/icons/chart.png" +local Description = "Display when a player is inside a PVP Sector" +local rect +local res +local DefaulPosition +local PVPMessage = '' +local AllowMoving +local player + +function PVPSector.initialize() + if onClient() then + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") + + rect = Rect(vec2(),vec2(190,25)) + res = getResolution(); + + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.7,res.y * 0.05) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) + + PVPSector.GetPVPStatus() + end + + Player():registerCallback("onSectorEntered", "onSectorEntered") +end + +function PVPSector.buildTab(tabbedWindow) +end + +function PVPSector.onPreRenderHud() + + if OverridePosition then + rect.position = OverridePosition + end + + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end + + + drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) + return + end + + drawTextRect('PVP Damage', rect,-1, 0,ColorRGB(1,1,1), 15, 0, 0, 0) + local Color = ColorRGB(0,1,0) + if PVPMessage == 'Enabled' then + Color = ColorRGB(1,0,0) + end + drawTextRect(PVPMessage, rect,1, 0,Color, 15, 0, 0, 0) +end + +function PVPSector.onSectorEntered(playerIndex) + PVPSector.GetPVPStatus() +end + +function PVPSector.GetPVPStatus(Message) + if onClient() then + if Message then + PVPMessage = Message + return + end + invokeServerFunction('GetPVPStatus') + return + end + + local PVP = Sector().pvpDamage + if PVP then + PVPMessage = 'Enabled' + else + PVPMessage = 'Disabled' + end + invokeClientFunction(Player(callingPlayer),'GetPVPStatus',PVPMessage) +end + +function PVPSector.updateClient(timeStep) + AllowMoving = MoveUI.AllowedMoving(player) +end + +function PVPSector.getUpdateInterval() + return 5 +end + +function PVPSector.setNewPosition(Position) + MoveUI.AssignPlayerOverride(Player(),Title,Position) +end + +return PVPSector diff --git a/mods/MoveUI/scripts/player/ResourcesUI.lua b/mods/MoveUI/scripts/player/ResourcesUI.lua index 52e9220..61f862d 100644 --- a/mods/MoveUI/scripts/player/ResourcesUI.lua +++ b/mods/MoveUI/scripts/player/ResourcesUI.lua @@ -10,38 +10,56 @@ local OverridePosition local Title = 'ResourcesUI' local Icon = "data/textures/icons/brick-pile.png" local Description = "Shows all your resources." +local rect +local res +local DefaulPosition +local resources = {} +local money = 0 +local AllowMoving +local player function ResourcesUI.initialize() - Player():registerCallback("onPreRenderHud", "onPreRenderHud") + if onClient() then + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") + + rect = Rect(vec2(),vec2(300,155)) + res = getResolution(); + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.92,res.y * 0.68) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) + + resources = {player:getResources()} + money = player.money + end end function ResourcesUI.buildTab(tabbedWindow) end function ResourcesUI.onPreRenderHud() - local rect = Rect(vec2(),vec2(300,155)) - local res = getResolution(); - - --MoveUI - Dirtyredz|David McClain - local DefaulPosition = vec2(res.x * 0.92,res.y * 0.68) - rect.position = MoveUI.CheckOverride(Player(),DefaulPosition,OverridePosition,Title) - OverridePosition, Moving = MoveUI.Enabled(Player(),rect,OverridePosition) - if OverridePosition and not Moving then - invokeServerFunction('setNewPosition',OverridePosition) + if OverridePosition then + rect.position = OverridePosition end - --MoveUI - Dirtyredz|David McClain - if MoveUI.AllowedMoving(Player()) then + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end + + drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) return end local HSplit = UIHorizontalMultiSplitter(rect, 10, 10, 7) - local resources = {Player():getResources()} drawTextRect('Credits', HSplit:partition(0),-1, 0,ColorRGB(1,1,1), 15, 0, 0, 0) - drawTextRect(MoveUI.NicerNumbers(Player().money), HSplit:partition(0),1, 0,ColorRGB(1,1,1), 15, 0, 0, 0) + drawTextRect(MoveUI.NicerNumbers(money), HSplit:partition(0),1, 0,ColorRGB(1,1,1), 15, 0, 0, 0) for i = 0, 6 do drawTextRect(Material(i).name, HSplit:partition(i+1),-1, 0,Material(i).color, 15, 0, 0, 0) @@ -49,6 +67,16 @@ function ResourcesUI.onPreRenderHud() end end +function ResourcesUI.updateClient(timeStep) + resources = {player:getResources()} + money = player.money + AllowMoving = MoveUI.AllowedMoving(player) +end + +function ResourcesUI.getUpdateInterval() + return 5 +end + function ResourcesUI.setNewPosition(Position) MoveUI.AssignPlayerOverride(Player(),Title,Position) end diff --git a/mods/MoveUI/scripts/player/ScrapyardLicenses.lua b/mods/MoveUI/scripts/player/ScrapyardLicenses.lua index 36d5c27..391cd70 100644 --- a/mods/MoveUI/scripts/player/ScrapyardLicenses.lua +++ b/mods/MoveUI/scripts/player/ScrapyardLicenses.lua @@ -15,14 +15,30 @@ local Title = 'ScrapyardLicenses' local Icon = "data/textures/icons/papers.png" local Description = "Shows all current Scrapyard Licenses, Displays Alliance Licenses if inside an Alliance Ship." local DefaultOptions = { - Both = false + Both = false, + Clickable = false } local Both_OnOff +local Clickable_OnOff +local rect +local res +local DefaulPosition +local player +local timeout = 0 +local AllowMoving function ScrapyardLicenses.initialize() if onClient() then - --Obviously - Player():registerCallback("onPreRenderHud", "onPreRenderHud") + player = Player() + + player:registerCallback("onPreRenderHud", "onPreRenderHud") + + rect = Rect(vec2(), vec2(400, 100)) + res = getResolution(); + --MoveUI - Dirtyredz|David McClain + DefaulPosition = vec2(res.x * 0.88, res.y * 0.21) + rect.position = MoveUI.CheckOverride(player,DefaulPosition,OverridePosition,Title) + else --Lets do some checks on startup/sector entered Player():registerCallback("onSectorEntered", "onSectorEntered") @@ -50,13 +66,19 @@ function ScrapyardLicenses.buildTab(tabbedWindow) local OptionsSplit = UIHorizontalMultiSplitter(mainSplit.bottom, 0, 0, 1) local TextVSplit = UIVerticalSplitter(OptionsSplit:partition(0),0, 5,0.65) - local name = container:createLabel(TextVSplit.left.lower, "Show Both", 16) + local name = container:createLabel(TextVSplit.left.lower, "Show Both", 16) --make sure variables are local to this file only Both_OnOff = container:createCheckBox(TextVSplit.right, "On / Off", 'onShowBoth') + Both_OnOff.tooltip = 'Shows both Alliance and Players licenses, othewise shows only license for the ship your driving.' + local TextVSplit = UIVerticalSplitter(OptionsSplit:partition(1),0, 5,0.65) + local name = container:createLabel(TextVSplit.left.lower, "Clickable", 16) + --make sure variables are local to this file only + Clickable_OnOff = container:createCheckBox(TextVSplit.right, "On / Off", 'onClickable') + Clickable_OnOff.tooltip = 'Allows you to click the UIs shown licenses. (can cause higher ping rates)' --Pass the name of the function, and the checkbox - return {onShowBoth = Both_OnOff} + return {onShowBoth = Both_OnOff, onClickable = Clickable_OnOff} end function ScrapyardLicenses.onShowBoth(checkbox, value) @@ -64,12 +86,18 @@ function ScrapyardLicenses.onShowBoth(checkbox, value) invokeServerFunction('setNewOptions', Title, {Both = value}) end +function ScrapyardLicenses.onClickable(checkbox, value) + --setNewOptions is a function inside entity/MoveUI.lua, that sets the options to the player. + invokeServerFunction('setNewOptions', Title, {Clickable = value}) +end + --Executed when the Main UI Interface is opened. function ScrapyardLicenses.onShowWindow() --Get the player options local LoadedOptions = MoveUI.GetOptions(Player(),Title,DefaultOptions) --Set the checkbox to match the option Both_OnOff.checked = LoadedOptions.Both + Clickable_OnOff.checked = LoadedOptions.Clickable end function ScrapyardLicenses.TableSize(tabl) @@ -84,39 +112,23 @@ end function ScrapyardLicenses.onPreRenderHud() if onClient() then - local rect = Rect(vec2(), vec2(400, 100)) - local res = getResolution(); - - local DefaulPosition = vec2(res.x * 0.88, res.y * 0.21) - rect.position = MoveUI.CheckOverride(Player(), DefaulPosition, OverridePosition, Title) - OverridePosition, Moving = MoveUI.Enabled(Player(), rect, OverridePosition) - if OverridePosition and not Moving then - invokeServerFunction('setNewPosition', OverridePosition) + if OverridePosition then + rect.position = OverridePosition end - if MoveUI.AllowedMoving(Player()) then + if AllowMoving then + OverridePosition, Moving = MoveUI.Enabled(rect, OverridePosition) + if OverridePosition and not Moving then + invokeServerFunction('setNewPosition', OverridePosition) + OverridePosition = nil + end + + drawTextRect(Title, rect, 0, 0,ColorRGB(1,1,1), 10, 0, 0, 0) return end - --get the licenses - local player = Player() - if not player then return end - local playerShip = Sector():getEntity(player.craftIndex) - if not playerShip then return end - local playerAlliance = player.allianceIndex - - local InAllianceShip = false - if playerShip then - if player.index ~= playerShip.factionIndex then - InAllianceShip = true - end - end - - ScrapyardLicenses.GetFactionValues(player.allianceIndex,player.index) - ScrapyardLicenses.sync() - local AllinaceLicensesSize = 0 if playerAlliance then AllinaceLicensesSize = ScrapyardLicenses.TableSize(AllianceValues) @@ -124,8 +136,9 @@ function ScrapyardLicenses.onPreRenderHud() local PlayerLicensesSize = ScrapyardLicenses.TableSize(PlayerValues) - local LoadedOptions = MoveUI.GetOptions(Player(),Title,DefaultOptions) + local LoadedOptions = MoveUI.GetOptions(player,Title,DefaultOptions) local showBoth = LoadedOptions.Both + local Clickable = LoadedOptions.Clickable local NumLicenses = 0 if showBoth then --if shoiwng both factions @@ -158,7 +171,9 @@ function ScrapyardLicenses.onPreRenderHud() drawTextRect(prepend..x..' : '..y, HSplit:partition(i), -1, 0, color, 15, 0, 0, 0) drawTextRect(createReadableTimeString(duration), HSplit:partition(i), 1, 0, color, 15, 0, 0, 0) - MoveUI.AllowClick(Player(),HSplit:partition(i),(function () GalaxyMap():show(x, y); print('Showing Galaxy:',x,y) end)) + if Clickable then + MoveUI.AllowClick(player,HSplit:partition(i),(function () GalaxyMap():show(x, y); print('Showing Galaxy:',x,y) end)) + end i = i + 1 end end @@ -180,7 +195,9 @@ function ScrapyardLicenses.onPreRenderHud() drawTextRect(prepend..x..' : '..y, HSplit:partition(i), -1, 0, color, 15, 0, 0, 0) drawTextRect(createReadableTimeString(duration), HSplit:partition(i), 1, 0, color, 15, 0, 0, 0) - MoveUI.AllowClick(Player(),HSplit:partition(i),(function () GalaxyMap():show(x, y); print('Showing Galaxy:',x,y) end)) + if Clickable then + MoveUI.AllowClick(player,HSplit:partition(i),(function () GalaxyMap():show(x, y); print('Showing Galaxy:',x,y) end)) + end i = i + 1 end end @@ -190,6 +207,45 @@ function ScrapyardLicenses.onPreRenderHud() end end +function ScrapyardLicenses.updateClient(timeStep) + local lx, ly = Sector():getCoordinates() + if PlayerValues[lx] then + if PlayerValues[lx][ly] then + PlayerValues[lx][ly] = PlayerValues[lx][ly] - 1 + end + end + if AllianceValues[lx] then + if AllianceValues[lx][ly] then + AllianceValues[lx][ly] = AllianceValues[lx][ly] - 1 + end + end + + timeout = timeout + timeStep + if timeout > 5 then + timeout = 0 + --get the licenses + local playerShip = Sector():getEntity(player.craftIndex) + if not playerShip then return end + local playerAlliance = player.allianceIndex + + local InAllianceShip = false + if playerShip then + if player.index ~= playerShip.factionIndex then + InAllianceShip = true + end + end + + ScrapyardLicenses.GetFactionValues(player.allianceIndex,player.index) + ScrapyardLicenses.sync() + + AllowMoving = MoveUI.AllowedMoving(player) + end +end + +function ScrapyardLicenses.getUpdateInterval() + return 1 +end + function ScrapyardLicenses.setNewPosition(Position) MoveUI.AssignPlayerOverride(Player(), Title, Position) end @@ -226,6 +282,7 @@ function ScrapyardLicenses.SetFactionValues(allianceIndex,allianceLicenses,playe invokeServerFunction('GetFactionValues',allianceIndex,allianceLicenses,playerLicenses) return end + if allianceIndex then local faction = Faction(allianceIndex) faction:setValue("MoveUI#Licenses", MoveUI.Serialize(allianceLicenses))