Progress Meter?
by Kevin James · in Torque Game Builder · 04/14/2010 (4:33 pm) · 2 replies
Does anyone have a progress meter class they would be willing to share?
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
Never would have thought of that... Kinda clever.
04/15/2010 (7:38 pm)
else{
if (isObject(%this.done)){
%this.Done.ProgressComplete();
}Never would have thought of that... Kinda clever.
Torque Owner Kevin James
function ProgressBar::GrowBar(%this,%increment) { %xSize=%this.BackBar.getSizeX(); if (%this.getSizeX()<(%xSize-%this.increment)){ %this.setSizeX(%this.getSizeX() + %increment); %xPos=%this.BackBar.getPositionX(); %this.setPosition((%xPos-%xSize/2)+(%this.getSizeX()/2), %this.getPositionY()); %this.BarId = %this.schedule(200,"GrowBar",%this.increment); } else{ if (isObject(%this.done)){ %this.Done.ProgressComplete(); } } }This progress bar consists of 3 elements: 1. Frame, 2. BackBar, and 3. Progress bar itself.
The BackBar is a black box behind the progress bar for contrast. The BackBar is mounted inside the frame. The progress bar is a green box off camera to start. Here is the basic setup:
function InfoBoxDisplay::StartResearch(%this) { ResearchBarFrame.Visible=true; ResearchBar.setPosition(ResearchBarFrame.getPosition()); ResearchBar.BackBar = ResearchBarBack; ResearchBar.setSizeX(0); ResearchBar.increment = 50/$ship.curResearch.Energy; ResearchBar.BarId = ResearchBar.schedule(500,"GrowBar",1); ResearchBar.Done=%this; }ProgressComplete is the event you need to code completion logic:
function InfoBoxDisplay::ProgressComplete(%this) { ResearchBarFrame.Visible=false; ResearchBar.setSizeX(0); //other specific code }I would have rather used someone else's tried and true method, but sometimes you just have to reinvent the wheel...