Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SRL_USE_REMOTEINPUT}
- {$I SRL/osr.simba}
- (*
- Slackdebug
- ==========
- Slacky's little drawing util pack.
- *)
- {$H-}
- (*
- .. pascal::
- const
- clProgRed = $1F2164;
- clProgBlue = $783F37;
- clProgGreen = $26B58A;
- clProgGreen2 = $12A20D;
- clProgBrown = $76ADB8;
- clProgLBlue = $B49946;
- clProgOrange = $1493E2;
- clProgPink = $A869C9;
- clProgYellow = $16D4F4;
- clProgGray = $B4BCBE;
- *)
- const
- clProgRed = $1F2164;
- clProgBlue = $783F37;
- clProgGreen = $26B58A;
- clProgGreen2 = $12A20D;
- clProgBrown = $76ADB8;
- clProgLBlue = $B49946;
- clProgOrange = $1493E2;
- clProgPink = $A869C9;
- clProgYellow = $16D4F4;
- clProgGray = $B4BCBE;
- function TFont.Create(name:String; size:Int32; fs:TFontStyles; fq:TFontQuality): TFont; static;
- begin
- Result.Init();
- Result.SetName(name);
- Result.SetSize(size);
- Result.SetStyle(fs);
- Result.SetQuality(fq);
- Result.SetColor($FFFFFF);
- end;
- var
- PROGGY_FONT_BAR := TFont.Create('Impact', 10, [fsBold], fqCleartype);
- PROGGY_FONT_H := TFont.Create('Impact', 10, [fsBold], fqCleartype);
- PROGGY_FONT := TFont.Create('Tahoma', 10, [fsBold], fqCleartype);
- procedure TMufasaBitmap.DrawText(txt:String; pt:TPoint; font:TFont;
- color:Int32; align:Int32=0; shadow:Boolean=False; shadowDir:Byte=0); overload;
- var
- W: Int32;
- begin
- Self.setFontName(font.getName());
- Self.setFontSize(font.getSize());
- Self.setFontAntialiasing(True);
- W := Self.TextWidth(txt);
- if align then
- pt := Point(pt.x-W, pt.y);
- if Shadow then
- begin
- case ShadowDir of
- 0: Self.DrawText(txt, pt, 1);
- 1: Self.DrawText(txt, pt+Point(1,0), 1);
- 2: Self.DrawText(txt, pt+Point(2,0), 1);
- 3: Self.DrawText(txt, pt+Point(2,1), 1);
- 4: Self.DrawText(txt, pt+Point(2,2), 1);
- 5: Self.DrawText(txt, pt+Point(1,2), 1);
- 6: Self.DrawText(txt, pt+Point(0,2), 1);
- 7: Self.DrawText(txt, pt+Point(0,1), 1);
- end;
- Self.DrawText(txt, pt+Point(1,1), color);
- end else
- begin
- Self.DrawText(txt, pt, color);
- end;
- end;
- procedure TMufasaBitmap.DrawTextNL(txt:TStringArray; pos:TPoint; font:TFont;
- color:Int32; align:Int32=0; shadow:Boolean=False; shadowDir:Byte=0);
- var
- i,hei:Int32;
- begin
- hei := Round(1.2 * abs(font.GetSize()));
- for i:=0 to High(txt) do
- begin
- Self.DrawText(txt[i],pos,font,color,align,shadow,shadowDir);
- inc(pos.y,hei);
- end;
- end;
- procedure TMufasaBitmap.DrawPrecentBar(pt:TPoint; w,h,percent:Int32; BgColor, BarColor:Int32; lText, rText:String);
- var
- B:TBox;
- tx,ty:Int32;
- f: Int32;
- begin
- B := [pt.x,pt.y,pt.x+w-1,pt.y+h-1];
- Self.DrawTPA(TPAFromBox(B), BgColor);
- B := B.Expand(-2);
- B.x2 := B.x1 + Round(B.Width() * (percent*0.01));
- Self.DrawTPA(TPAFromBox(B), BarColor);
- tx := B.x1 + (W div 2) - 8;
- ty := B.y1 + (H - PROGGY_FONT_BAR.GetSize()) div 2 - 1;
- Self.DrawText(ToStr(percent)+'%', Point(tx,ty), PROGGY_FONT_BAR, $FFFFFF, 0, True, 4);
- Self.DrawText(lText, Point(b.x1+4,ty), PROGGY_FONT_BAR, $FFFFFF, 0, True, 4);
- Self.DrawText(rText, Point(pt.x+w-6,ty), PROGGY_FONT_BAR, $FFFFFF, 1, True, 4);
- end;
- (*
- TMufasaBitmap.DrawSkillReport
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- .. pascal::
- function TMufasaBitmap.DrawSkillReport(At: TPoint; Color:Int32; CurrentXP, GainedXP, Objectives: Int32; Skill:String=''): TBox;
- Draws a skill report at the given location. Color can be just about any color, it will be adjusted
- automatically to look as good as possible.
- You have to track your XP, gained XP, and how many "objects" you have complted yourself in your script.
- This is only for debugging that.
- *)
- function TMufasaBitmap.DrawSkillReport(At: TPoint; Color:Int32; CurrentXP, GainedXP, Objectives: Int32; Skill:String=''): TBox; constref;
- var
- w,h,z,currLvl,atNextLvl,atCurrLvl,rem,percent: Int32;
- runtime: UInt32;
- txt1,txt2: TStringArray;
- buffer: TMufasaBitmap;
- Hue,S,L:Extended;
- function Light(Color: TColor): Double;
- begin
- Result := (0.12 * (Color and $FF) + 0.58 * (Color shr 8 and $FF) + 0.30 * (Color shr 16 and $FF)) / 3;
- end;
- //this is a cheat to better blend title text later on.
- procedure BlendTitleCheat(b: TBox; where: TPoint);
- var tmp: TMufasaBitmap;
- begin
- buffer.SetFontName(PROGGY_FONT_H.GetName());
- buffer.SetFontSize(PROGGY_FONT_H.GetSize()+2);
- tmp.FromClient([At.X+4, At.y, At.X+buffer.TextWidth(Skill), At.y+PROGGY_FONT_H.GetSize()]);
- buffer.DrawBitmap(tmp, [5,2]);
- tmp.Free();
- end;
- begin
- if Skill <> '' then z := 6;
- Result := [At.X, At.Y, At.X+215, At.Y+50+z];
- W := Result.Width;
- H := Result.Height;
- ColorToHSL(Color, Hue,S,L);
- runtime := GetTimeRunning();
- currLvl := srl.GetLevelAtXP(CurrentXP);
- atCurrLvl := srl.GetXPAtLevel(currLvl);
- atNextLvl := srl.GetXPAtLevel(currLvl+1);
- rem := atNextLvl - CurrentXP;
- percent := 100 - Round(rem / (atNextLvl - atCurrLvl) * 100);
- try
- buffer.Init(client.GetMBitmaps);
- buffer.SetSize(W,H);
- BlendTitleCheat([At.X+4, At.y, At.X+buffer.TextWidth(Skill), At.y+PROGGY_FONT_H.GetSize()], [5,2]);
- buffer.DrawBoxFilled(Box(0,z,W-1,H-1), False, HSLToColor(Hue, S*0.5, Min(24,L*0.7)));
- buffer.DrawTPA([[0,z],[W-1,z],[0,H-1],[W-1,H-1]], 0);
- buffer.DrawPrecentBar(
- [3,3+z], 210, 20, percent, //pos, w,h, percent
- HSLToColor(Hue, S*0.6, Min(15,Light(Color)*0.25)), Color, //colors
- 'Lvl: '+ToStr(CurrLvl), //left-text
- 'Lvl: '+ToStr(CurrLvl+1) //right-text
- );
- txt1 := ['Uptime: ' + srl.MsToTime(runtime, Time_Bare),
- 'Exp Gained: ' + srl.FormatNumber(GainedXP, 1)];
- txt2 := ['Exp/Hour: ' + srl.FormatNumber(GainedXP / (runtime / ONE_HOUR), 1),
- 'Count: ' + ToStr(Objectives)];
- buffer.DrawTextNL(txt1, Point(3, 25+z), PROGGY_FONT, $FFFFFF, 0, True, 4);
- buffer.DrawTextNL(txt2, Point(115,25+z), PROGGY_FONT, $FFFFFF, 0, True, 4);
- if Skill <> '' then
- buffer.DrawText(Skill, Point(5,2), PROGGY_FONT_H, $FFFFFF, 0, False, 4);
- buffer.DrawTransparent(At.X,At.Y, Self);
- except
- WriteLn('Error: DrawSkillReport -> Something went wrong');
- finally
- buffer.Free();
- end;
- end;
- begin
- AddOnTerminate(@PROGGY_FONT.Free);
- end;
- begin
- // examples:
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,40], $907000, 10000, 3000, 124, 'FISHING');
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,100], $006070, 10000, 3000, 124, 'MINING');
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,160], $AA00AA, 10000, 3000, 124, 'WOODCUTTING');
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,220], $777777, 10000, 3000, 124, 'SMITHING');
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,280], $222222, 10000, 3000, 124, 'MAGIC');
- RSClient.Image().DrawSkillReport([MainScreen.Width-450,340], clProgRed, 10000, 3000, 124, "SLACKY'S MINER");
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement