--***************************************************************************** --* File: lua/modules/ui/controls/worldview.lua --* Author: Chris Blackwell --* Summary: World view control --* --* Copyright © 2005 Gas Powered Games, Inc. All rights reserved. --***************************************************************************** local UIUtil = import('/lua/modules/ui/uiutil.lua') local Control = import('/lua/modules/maui/control.lua').Control WorldView = Class(moho.UIWorldView, Control) { Cursor = nil, bMouseIn = false, EventRedirect = nil, HandleEvent = function(self, event) if self.EventRedirect then return self.EventRedirect(self,event) end if event.Type == 'MouseEnter' or event.Type == 'MouseMotion' then self.bMouseIn = true if self.Cursor then GetCursor():SetTexture(unpack(self.Cursor)) else GetCursor():Reset() end elseif event.Type == 'MouseExit' then self.bMouseIn = false GetCursor():Reset() end return false end, OnUpdateCursor = function(self) local mode = import('/lua/modules/ui/game/commandmode.lua').GetCommandMode() if mode[1] == "order" then if self:ShowConvertToPatrolCursor() then self.Cursor = {UIUtil.GetCursor("MOVE2PATROLCOMMAND")} else self.Cursor = {UIUtil.GetCursor(mode[2])} end elseif mode[1] == "build" then self.Cursor = {UIUtil.GetCursor('BUILD')} elseif self:HasHighlightCommand() then if self:ShowConvertToPatrolCursor() then self.Cursor = {UIUtil.GetCursor("MOVE2PATROLCOMMAND")} else self.Cursor = {UIUtil.GetCursor('HOVERCOMMAND')} end else local order = self:GetRightMouseButtonOrder() if order then self.Cursor = {UIUtil.GetCursor(order)} else self.Cursor = nil end -- catches if there is no order, or if there is no cursor assigned to the order if not self.Cursor then GetCursor():Reset() end end self:ApplyCursor() end, OnCommandDragBegin = function(self) self.Cursor = {UIUtil.GetCursor("DRAGCOMMAND")} self:ApplyCursor() end, OnCommandDragEnd = function(self) self:OnUpdateCursor() end, ApplyCursor = function(self) if self.Cursor and self.bMouseIn then GetCursor():SetTexture(unpack(self.Cursor)) end end, }