lotrointerface.com
Search Downloads

LoTROInterface SVN Calendar

[/] [Release_3.3/] [FrostyPlugins/] [CustomPluginsManager/] [IconEntryWindow.lua] - Rev 33

Compare with Previous | Blame | View Log

import "Turbine";
import "Turbine.Gameplay";
import "Turbine.UI";
import "Turbine.UI.Extensions";
import "Turbine.UI.Lotro";
import "Turbine.Utils";
import "FrostyPlugins.CustomPluginsManager.PluginSlot"

-- -----------------------------------------------------------------------
-- IconEntryWindow is a popup window owned by the CustomPluginsManager to
-- allow the user to change the location of the icon for a plugin
-- -----------------------------------------------------------------------

IconEntryWindow = class( Turbine.UI.Window);

-- --------------------------------------------------------------
-- Constructor
--
-- Description: this is where the window is laid out, the fields
-- are created, and events are trapped.
-- --------------------------------------------------------------
function IconEntryWindow:Constructor()
        Turbine.UI.Window.Constructor( self );

  -- we will communicate back to the main window
  self.owner = nil;
  
  -- --------------------------------------------
  -- window layout
  -- --------------------------------------------
  
        -- set window properties
  self:SetBackground( "FrostyPlugins/CustomPluginsManager/Resources/TooltipBackground.tga" );
  self:SetBackColorBlendMode( Turbine.UI.BlendMode.Overlay );
        self:SetSize( 300, 88 );
        self:SetOpacity( 1 );
        self:SetAllowDrop( false );
        self:SetMouseVisible( false );

  -- create various labels
  self.InstructionsLabel = Turbine.UI.Label();
  self.InstructionsLabel:SetForeColor( Turbine.UI.Color( 0.75, 0.75, 0 ) );
  self.InstructionsLabel:SetMultiline( false );
        self.InstructionsLabel:SetParent( self );
  self.InstructionsLabel:SetPosition( 5, 5 );
  self.InstructionsLabel:SetSize( 290, 13 );
  self.InstructionsLabel:SetText( "Enter the plugin icon path, e.g.:" );

  self.ExampleLabel = Turbine.UI.Label();
  self.ExampleLabel:SetForeColor( Turbine.UI.Color( 0.75, 0.75, 0 ) );
  self.ExampleLabel:SetMultiline( false );
        self.ExampleLabel:SetParent( self );
  self.ExampleLabel:SetPosition( 5, 18 );
  self.ExampleLabel:SetSize( 290, 13 );
  self.ExampleLabel:SetText( "TurbinePlugins\\Vitals\\Resources\\Icon.tga" );

  -- create the text box fields
  self.iconTextBox = Turbine.UI.Lotro.TextBox();
  self.iconTextBox:SetFont( Turbine.UI.Lotro.Font.Verdana14 );
  self.iconTextBox:SetMultiline( true );
        self.iconTextBox:SetParent( self );
  self.iconTextBox:SetPosition( 5, 31 );
  self.iconTextBox:SetSize( 290, 30 );

  -- create the OK and Cancel buttons
  self.OkButton = Turbine.UI.Lotro.Button();
        self.OkButton:SetParent( self );
        self.OkButton:SetPosition( 30, 63 );
        self.OkButton:SetSize( 80, 25 );
        self.OkButton:SetText( "Save" );
        self.OkButton:SetVisible( true );

  self.OkButton.Click = function( sender, args )
    if( self.owner ) then
      self.owner:UpdateIcon( self.pluginName, self.iconTextBox:GetText() );
    end
        end
  
        self.CancelButton = Turbine.UI.Lotro.Button();
        self.CancelButton:SetParent( self );
        self.CancelButton:SetPosition( 190, 63 );
        self.CancelButton:SetSize( 80, 25 );
        self.CancelButton:SetText( "Cancel" );
        self.CancelButton:SetVisible( true );

  self.CancelButton.Click = function( sender, args )
          self:Shutdown();
        end

  -- --------------------------------------------
  -- event handling
  -- --------------------------------------------
        -- make sure we listen for key presses
        self:SetWantsKeyEvents( true );

  --
  -- if the escape key is pressed, hide the window
  --
        self.KeyDown = function( sender, args )
                -- do this if the escape key is pressed
                if ( args.Action == Turbine.UI.Lotro.Action.Escape ) then
                        sender:SetVisible( false )
                end
        end
end


-- --------------------------------------------------------------
-- Initialize
--
-- Description: Initialize the window with information from the
-- plugin slot and show the window
-- --------------------------------------------------------------
function IconEntryWindow:Initialize( pluginSlot, owner )
  -- the window is owned by the CustomPluginsManager
  self.owner = owner;
  
  -- populate the icon directory here
  self.pluginName = pluginSlot.PluginName;
  self.iconTextBox:SetText( pluginSlot.PluginIcon );
  
  self:SetVisible( true );
end

-- --------------------------------------------------------------
-- Shutdown
--
-- Description: Hide the window
-- --------------------------------------------------------------
function IconEntryWindow:Shutdown()
  self:SetVisible( false );
end

Compare with Previous | Blame


All times are GMT -5. The time now is 04:27 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui