Jump to content

PostGUI and Color


Alcatrik

Recommended Posts

Has anybody been having any issues with PostGUI and Color in dxDrawImage and dxDrawImageSection? Neither seem to do anything in my code here:

bjVT

  
MetaRPG.AnimatedImage = {} 
  
  
local STATIC = MetaRPG.AnimatedImage 
local CLASS = {} 
  
-- MetaRPG.AnimatedImage.Create 
--  image: (string) the image path. 
--  x: (number) position on screen to display it. 
--  y: (number) position on screen to display it. 
--  width: (number) how wide you want it to display on screen. 
--  height: (number) how high. 
--  frames: (number) number of frames to the image 
--  frame_width: (number) the width of each frame. 
--  [times]: (number) how many times to do it. 0 for repeat infinitely. 
--  [delay]: (number) milliseconds per frame change. 
--  [rotation]: (number) rotation of the image. 
--  [etc]... 
  
function STATIC.Create(image, x, y, width, height, frames, frame_width, times, delay, rotation, rotationCenterOffsetX, rotationCenterOffsetY, color, postgui) 
    local C = table.copy(CLASS) 
     
    -- set values 
    C.Data = 
    { 
        image = image, 
        x = x, 
        y = y, 
        width = width, 
        height = height, 
        frames = frames, 
        frame_width = frame_width, 
        times = times or 0, -- optional 
        delay = delay or 1000, -- optional 
        rotation = rotation, -- optional  
        rotationCenterOffsetX = rotationCenterOffsetX, -- optional 
        rotationCenterOffsetY = rotationCenterOffsetY, -- optional 
        color = color, -- optional  
        postgui = postgui, -- optional 
         
         
        -- INTERNAL 
        _Idx = 0, 
        _XOffset = 0, 
        _Iterations = 0 -- How many times it has ran. Compared with C.Data.times. 
    } 
     
    -- set the event handler and the timer 
    addEventHandler("onClientRender", getRootElement(), function () return C:Render() end) 
    C.Data._Timer = setTimer(function () C:Think() end, C.Data.delay, C.Data.frames * C.Data.times - 1) 
     
    -- output a debug msg 
    outputDebugString("Called: MetaRPG.AnimatedImage.Create(" .. image .. ");") 
     
    return C 
end 
  
-- Handles the animation aspect of it. 
function CLASS:Think() 
    local frames, idx = self.Data.frames, self.Data._Idx + 1 
     
    if (idx > frames-1) then 
        idx = 0 
    end 
     
    -- We set the Idx here rather than using it all along JUST in case a frame renders while this function loads. We also 
    -- set a predefined offset to save time in onClientRender. 
    self.Data._Idx = idx 
    self.Data._XOffset = idx * self.Data.frame_width     
end 
  
-- Handles the "drawing" of it to screen. 
function CLASS:Render() 
    dxDrawImageSection(self.Data.x, self.Data.y, self.Data.width, self.Data.height,  
        self.Data._XOffset, 0, self.Data.frame_width, self.Data.height, self.Data.image, 
        self.Data.rotation, self.Data.rotationCenterOffsetX, self.Data.rotationCenterOffsetY, 
        self.Data.color, self.Data.postgui) 
end 
  
-- Handles the destruction of it. 
function CLASS:Dispose() 
    killTimer(self._Timer) 
    removeEventHandler("onClientRender", getRootElement(), self.Render) 
end 
  

  
function GUI:Draw(percentage, message) 
     
    [...] 
  
    -- The components. 
    local COMPONENT = self.Components 
     
    COMPONENT.AnimImg = MetaRPG.AnimatedImage.Create("resources/loading_360px.png", ScrW/2-30, ScrH/2-30, 60, 60, 12, 60, nil, 50, nil, nil, nil, nil, true) --ScrW/2-180, ScrH/2-15, 360, 60, 360, 9, nil, nil, nil, nil, nil, true) 
    COMPONENT.Label = guiCreateLabel(25, 140, 350, 25, message, false, self.Container) 
    COMPONENT.ProgressBar = guiCreateProgressBar(25, 160, 350, 25, false, self.Container) 
     
    guiLabelSetHorizontalAlign(COMPONENT.Label, "center") 
    guiProgressBarSetProgress(COMPONENT.ProgressBar, percentage) 
end 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...