Jesus4Lyf
Good Idea™
- Reaction score
- 397
I don't think so. I might not even use it at all if you did.
Ok, so should I implement ARGB then?
I don't think so. I might not even use it at all if you did.
Well, I don't know (And don't really intend to learn) cJASS or Zinc... Is it recommended ?
>cJASS or Zinc... Is it recommended ?
It is not actually allowed, let alone recommended.
Ok, just came up with an idea... Maybe you'd like to be able to queue up the modifications, so that if the unit is currently scaling and you scale it again, you can queue the last scale so that when the first one is done, the next one starts ?
function somethingSomethingByARGB takes integer x returns nothing
static if ( LIBRARY_ARGB) then
call bleh ( ARGB(x).red, ARGB(x).green, ARGB(x).blue ) ...
else
debug call BJDebugMsg("somethingSomethingByARGB called but ARGB is not in the map!")
endif
endfunction
Yeah, I wouldn't mind if there were a couple functions that faded to an aarrggbb endpoint instead of having to modify the values by a certain amount.
PS: set col = 0xFF448909 is incredibly easier to use than col = something.create(0xFF448909) ... col.destroy(). ARGB is meant so that the user can have constants such as constant ARGB initialColor = 0xFF450023 , most people are already quite used to such hex codes due to tooltips, so it is easier that way... It is not standard but it is great at solving this color setting issue that is so common.
But how would I go about doing this:
struct SmoothScaleChange
private integer ticks
private real increment
private unit u
private method periodic takes nothing returns boolean
set this.ticks = this.ticks - 1
call ModifyUnitScale( this.u, this.increment ) // This will save the scale of the unit in a struct using AIDS...
debug call BJDebugMsg( "SUM Scaling: " + R2S( Appearance[ this.u ].scale ) )
if this.ticks <= 0 then
call this.destroy() // When ticks becomes 0 (Meaning that the scaling is done) destroy it ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />
return true
endif
return false
endmethod
implement T32
static method create takes unit Scaler, real Time, real scaleMod, real endScale returns thistype
local thistype this = thistype.allocate()
local real scale = GetUnitScale( Scaler )
local real scalechange = endScale - scale
set this.u = Scaler // Which unit to scale XD
// How much the scale will change each PERIOD...
if scaleMod == 0.0 then
set this.increment = ( ( scalechange * T32_PERIOD ) / Time )
set this.ticks = R2I( scalechange / this.increment ) // How many times the timer must fire...
else
set this.increment = ( ( scaleMod * T32_PERIOD ) / Time )
set this.ticks = R2I( scaleMod / this.increment ) // How many times the timer must fire...
endif
call this.startPeriodic()
return this
endmethod
endstruct
library UnitAppearance requires AIDS
struct Appearance extends array
//! runtextmacro AIDS()
real scale
real alpha
real red
real green
real blue
private method AIDS_onCreate takes nothing returns nothing
set this.scale = 1.00
set this.alpha = 255.00
set this.red = 255.00
set this.green = 255.00
set this.blue = 255.00
endmethod
endstruct
function ModifyUnitScale takes unit whichUnit, real increment returns nothing
local Appearance this = Appearance[whichUnit]
set this.scale = this.scale + increment
call SetUnitScale(whichUnit, this.scale, 0.00, 0.00)
endfunction
function ModifyUnitVertexColor takes unit whichUnit, real alphaIncrement, real redIncrement, real greenIncrement, real blueIncrement returns nothing
local Appearance this = Appearance[whichUnit]
set this.alpha = this.alpha + alphaIncrement
set this.red = this.red + redIncrement
set this.green = this.green + greenIncrement
set this.blue = this.blue + blueIncrement
call SetUnitVertexColor(whichUnit, R2I(this.red), R2I(this.green), R2I(this.blue), R2I(this.alpha))
endfunction
endlibrary
//! zinc
library SmoothUnitMod requires T32, UnitAppearance
{
//===========================================================================
type ModificationFunction extends function(unit, real);
function SetScale(unit whichUnit, real increment)
{
ModifyUnitScale(whichUnit, increment);
}
function SetA(unit whichUnit, real increment)
{
ModifyUnitVertexColor(whichUnit, increment, 0.00, 0.00, 0.00);
}
function SetR(unit whichUnit, real increment)
{
ModifyUnitVertexColor(whichUnit, 0.00, increment, 0.00, 0.00);
}
function SetG(unit whichUnit, real increment)
{
ModifyUnitVertexColor(whichUnit, 0.00, 0.00, increment, 0.00);
}
function SetB(unit whichUnit, real increment)
{
ModifyUnitVertexColor(whichUnit, 0.00, 0.00, 0.00, increment);
}
//===========================================================================
public struct SmoothMod
{
private unit whichUnit;
private real increment;
private ModificationFunction modFunc;
//===========================================================================
static method scale(unit whichUnit, real duration, real value)
{
SmoothMod sm = SmoothMod.allocate();
sm.whichUnit = whichUnit;
sm.increment = value / duration * T32_PERIOD;
sm.modFunc = SetScale;
sm.ticks = R2I(duration / T32_PERIOD);
sm.startPeriodic();
}
static method alpha(unit whichUnit, real duration, real value)
{
SmoothMod sm = SmoothMod.allocate();
sm.whichUnit = whichUnit;
sm.increment = value / duration * T32_PERIOD;
sm.modFunc = SetA;
sm.ticks = R2I(duration / T32_PERIOD);
sm.startPeriodic();
}
static method red(unit whichUnit, real duration, real value)
{
SmoothMod sm = SmoothMod.allocate();
sm.whichUnit = whichUnit;
sm.increment = value / duration * T32_PERIOD;
sm.modFunc = SetR;
sm.ticks = R2I(duration / T32_PERIOD);
sm.startPeriodic();
}
static method green(unit whichUnit, real duration, real value)
{
SmoothMod sm = SmoothMod.allocate();
sm.whichUnit = whichUnit;
sm.increment = value / duration * T32_PERIOD;
sm.modFunc = SetG;
sm.ticks = R2I(duration / T32_PERIOD);
sm.startPeriodic();
}
static method blue(unit whichUnit, real duration, real value)
{
SmoothMod sm = SmoothMod.allocate();
sm.whichUnit = whichUnit;
sm.increment = value / duration * T32_PERIOD;
sm.modFunc = SetB;
sm.ticks = R2I(duration / T32_PERIOD);
sm.startPeriodic();
}
//===========================================================================
implement T32;
private integer ticks;
private method periodic() -> boolean
{
this.ticks = this.ticks - 1;
if (this.ticks <= 0)
{
this.destroy();
return true;
}
else
{
this.modFunc.execute(this.whichUnit, this.increment);
return false;
}
}
}
}
//! endzinc