Advertisement
WarPie90

Web walk generator

Feb 8th, 2018
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 41.96 KB | None | 0 0
  1. program MY_TSlackGUI;
  2. {$I SRL/OSR.simba}
  3. {$I SlackGUI/SlackGUI.simba}
  4. {$H-}
  5.  
  6. type
  7.   TWebGraph = record
  8.     Nodes: TPointArray;
  9.     Paths: T2DIntArray;
  10.   end;
  11.  
  12. var
  13.   // forms stuff
  14.   WorldImg: TMufasaBitmap;
  15.   CurrX, CurrY, tmpX, tmpY, StartX, StartY: Int32;
  16.   IsDragging, IsDraggingNode, IsTesting: Boolean;
  17.  
  18.   // node stuff
  19.   NodeCount: Int32;
  20.   InFocus: Int32 = -1;
  21.   Graph: TWebGraph;
  22.  
  23.   TestPath: TIntArray;
  24.  
  25.  
  26. function ToString(X: TPoint): String; override;
  27. begin
  28.   Result := '['+ToString(X.X)+','+ToString(X.Y)+']';
  29. end;
  30.  
  31. function ToString(X: TPointArray): String; override;
  32. var i: Int32;
  33. begin
  34.   Result := '[';
  35.   for i:=0 to High(X)-1 do Result += ToString(X[i])+',';
  36.   Result += ToString(X[High(X)]);
  37.   Result += ']';
  38. end;
  39.  
  40. function LinesIntersect(p,q:array[0..1] of TPoint; out i:TPoint): Boolean;
  41. var
  42.   dx,dy,d: TPoint;
  43.   dt,s,t: Double;
  44.   function Det(a,b: TPoint): Int64;
  45.   begin
  46.     Result := a.x*b.y - a.y*b.x;
  47.   end;
  48. begin
  49.   dx := [p[0].x - p[1].x, q[0].x - q[1].x];
  50.   dy := [p[0].y - p[1].y, q[0].y - q[1].y];
  51.   dt := det(dx, dy);
  52.   if dt = 0 then Exit(False);
  53.   d := [Det(p[0],p[1]), Det(q[0],q[1])];
  54.   i.x := Round(Det(d, dx) / dt);
  55.   i.y := Round(Det(d, dy) / dt);
  56.   s := (dx.x * (q[0].y-p[0].y) + dy.x * (p[0].x-q[0].x)) / dt;
  57.   t := (dx.y * (p[0].y-q[0].y) + dy.y * (q[0].x-p[0].x)) / (-dt);
  58.   Result := (s > 0) and (s < 1) and (t > 0) and (t < 1);
  59. end;
  60.  
  61. function CheckForNearbyNode(p: TPoint): Int32;
  62. var i:Int32;
  63. begin
  64.   Result := -1;
  65.   for i:=0 to High(Graph.Nodes) do
  66.     if Distance(p,Graph.Nodes[i]) < 5 then
  67.       Exit(i);
  68. end;
  69.  
  70. function InvalidPath(p,q: TPoint): Boolean;
  71. var
  72.   i,n: Int32;
  73.   l1,l2: array[0..1] of TPoint;
  74.   _: TPoint;
  75. begin
  76.   l1 := [p,q];
  77.   for i:=0 to High(Graph.Paths) do
  78.   begin
  79.     l2[0] := Graph.Nodes[i];
  80.     for n in Graph.Paths[i] do
  81.     begin
  82.       l2[1] := Graph.Nodes[n];
  83.       if (l1[0] = l2[0]) and (l1[1] = l2[1]) then
  84.         Continue;
  85.       if LinesIntersect(l1,l2,_) then
  86.         Exit(True);
  87.     end;
  88.   end;
  89. end;
  90.  
  91. procedure AddNode(p: TPoint);
  92. var
  93.   c: Int32;
  94. begin
  95.   if (InFocus <> -1) and (InvalidPath(p,Graph.Nodes[InFocus])) then
  96.   begin
  97.     WriteLn('Error: Path crosses another path');
  98.     Exit;
  99.   end;
  100.   c := NodeCount;
  101.   Inc(NodeCount);
  102.   SetLength(Graph.Nodes, NodeCount);
  103.   SetLength(Graph.Paths, NodeCount);
  104.  
  105.   Graph.Nodes[c] := p;
  106.   if InFocus = -1 then
  107.     InFocus := c
  108.   else
  109.   begin
  110.     Graph.Paths[InFocus] += c;
  111.     Graph.Paths[c] += InFocus;
  112.   end;
  113. end;
  114.  
  115. procedure ConnectNodes(a,b: Int32);
  116. var
  117.   i,n: Int32;
  118.   p: TPoint;
  119.   l1,l2: array[0..1] of TPoint;
  120. begin
  121.   if InIntArray(Graph.Paths[a], b) then
  122.   begin
  123.     Graph.Paths[a].Remove(b);
  124.     Graph.Paths[b].Remove(a);
  125.   end else
  126.   begin
  127.     if (InvalidPath(Graph.Nodes[a],Graph.Nodes[b])) then
  128.     begin
  129.       WriteLn('Error: Path crosses another path');
  130.       Exit;
  131.     end;
  132.  
  133.     Graph.Paths[a] += b;
  134.     Graph.Paths[b] += a;
  135.   end;
  136.   (*
  137.   l1 := [Graph.Nodes[a], Graph.Nodes[b]];
  138.   SetLength(l2, 2);
  139.   for i:=0 to High(Graph.Paths) do
  140.   begin
  141.     l2[0] := Graph.Nodes[i];
  142.     for n in Graph.Paths[i] do
  143.     begin
  144.       l2[1] := Graph.Nodes[n];
  145.       if LinesIntersect(l1,l2,p) then
  146.       begin
  147.  
  148.       end;
  149.     end;
  150.   end;
  151.   *)
  152. end;
  153.  
  154. procedure DeleteNode(node: Int32);
  155. var
  156.   i,j,n,curr: Int32;
  157.   marked: TIntArray;
  158. begin
  159.   marked += node;
  160.   repeat
  161.     curr := marked.Pop();
  162.  
  163.     for n in Graph.Paths[curr] do
  164.     begin
  165.       Graph.Paths[n].Remove(curr, True);
  166.       if Length(Graph.Paths[n]) = 0 then
  167.         marked += n;
  168.     end;
  169.  
  170.     // offset remainding nodes
  171.     for i:=0 to High(Graph.Paths) do
  172.       for j:=0 to High(Graph.Paths[i]) do
  173.         if Graph.Paths[i][j] > curr then
  174.           Dec(Graph.Paths[i][j]);
  175.  
  176.     for i:=0 to High(marked) do
  177.       if marked[i] > curr then Dec(marked[i]);
  178.  
  179.     // remove the node itself
  180.     Delete(Graph.Paths, curr, 1);
  181.     Delete(Graph.Nodes, curr, 1);
  182.     Dec(NodeCount);
  183.   until Length(marked) = 0;
  184. end;
  185.  
  186. function FindPath(Graph: TWebGraph; Start, Goal: Int32): TIntArray;
  187. type
  188.   TNode = record
  189.     Indices: TIntArray;
  190.     Score: Double;
  191.   end;
  192. var
  193.   queue: array of TNode;
  194.   visited: TBoolArray;
  195.   cIdx, pathIdx, n: Int32;
  196.   current, node: TNode;
  197.   altPaths: array of TIntArray;
  198.   p,q: TPoint;
  199.  
  200.   function GetNextShortest(): TNode;
  201.   var i,node: Int32;
  202.   begin
  203.     Result := queue[0];
  204.     for i:=0 to High(queue) do
  205.       if queue[i].Score < Result.Score then
  206.       begin
  207.         node   := i;
  208.         Result := queue[i];
  209.       end;
  210.     Delete(queue, node, 1);
  211.   end;
  212. begin
  213.   queue   := [[[start],0]];
  214.   SetLength(visited, Length(Graph.Nodes));
  215.  
  216.   while Length(queue) <> 0 do
  217.   begin
  218.     current := GetNextShortest();
  219.     cIdx := current.Indices[High(current.Indices)];
  220.     if Visited[cIdx] then Continue; //skip overwrapping paths..
  221.     Visited[cIdx] := True;
  222.  
  223.     if (cIdx = Goal) then
  224.     begin
  225.       Exit(current.Indices);
  226.     end;
  227.  
  228.     p := Graph.Nodes[cIdx];
  229.     for pathIdx in Graph.Paths[cIdx] do
  230.     begin
  231.       if not Visited[pathIdx] then
  232.       begin
  233.         q := Graph.Nodes[pathIdx];
  234.         node.Indices := current.Indices + pathIdx;
  235.         node.Score   := current.Score + Hypot(p.x-q.x, p.y-q.y);
  236.         queue += node;
  237.       end;
  238.     end;
  239.   end;
  240. end;
  241.  
  242. procedure DrawWeb(Image: TMufasaBitmap; X1,Y1: Int32; Graph: TWebGraph);
  243. var
  244.   W,H,i,j: Int32;
  245.   p,q: TPoint;
  246.   Nodes,line: TPointArray;
  247. begin
  248.   W := Image.GetWidth-1;
  249.   H := Image.GetHeight-1;
  250.  
  251.   Nodes := Copy(Graph.Nodes);
  252.   Nodes.Offset(Point(-X1,-Y1));
  253.  
  254.   for i:=0 to High(Graph.Paths) do
  255.   begin
  256.     p := Nodes[i];
  257.     if (not InRange(p.x,4,W-4)) or (not InRange(p.y,4,H-4)) then
  258.       continue;
  259.  
  260.     for j:=0 to High(Graph.Paths[i]) do
  261.     begin
  262.       q := Nodes[Graph.Paths[i][j]];
  263.       line := TPAFromLine(p.x,p.y,q.x,q.y);
  264.       FilterPointsBox(line,0,0,W,H);
  265.       Image.DrawTPA(line, $77FF77);
  266.     end;
  267.   end;
  268.  
  269.   for i:=0 to High(Nodes) do
  270.     if InRange(Nodes[i].x,4,W-5) and InRange(Nodes[i].y,4,H-5) then
  271.     begin
  272.       if InFocus = i then
  273.         Image.DrawCircle(Nodes[i],4,True,$FF0000)
  274.       else
  275.         Image.DrawCircle(Nodes[i],3,True,$0000FF);
  276.     end;
  277. end;
  278.  
  279. procedure DrawPath(Image: TMufasaBitmap; X1,Y1: Int32; Path: TIntArray; Graph: TWebGraph);
  280. var
  281.   i,W,H: Int32;
  282.   p,q: TPoint;
  283.   Nodes,line: TPointArray;
  284. begin
  285.   W := Image.GetWidth-1;
  286.   H := Image.GetHeight-1;
  287.  
  288.   Nodes := Copy(Graph.Nodes);
  289.   Nodes.Offset(Point(-X1,-Y1));
  290.  
  291.   p := Nodes[Path[0]];
  292.   q := Nodes[Path[High(Path)]];
  293.  
  294.   if InRange(p.x,8,W-8) and InRange(p.y,8,H-8) then
  295.     Image.DrawCircle(p, 8, True, $0000FF);
  296.  
  297.   if InRange(q.x,8,W-8) and InRange(q.y,8,H-8) then
  298.     Image.DrawCircle(q, 8, True, $FF0000);
  299.  
  300.   for i:=0 to High(Path) do
  301.   begin
  302.     p := Nodes[Path[i]];
  303.     if InRange(p.x,4,W-4) and InRange(p.y,4,H-4) then
  304.       Image.DrawCircle(p,3,True, 0);
  305.  
  306.     if i < High(Path) then
  307.     begin
  308.       q := Nodes[Path[i+1]];
  309.       line := TPAFromLine(p.x,p.y,q.x,q.y);
  310.       FilterPointsBox(line,0,0,W,H);
  311.       Image.DrawTPA(line, 0);
  312.     end;
  313.   end;
  314. end;
  315.  
  316. // -----------------------------------------------------------------------------
  317. // -----------------------------------------------------------------------------
  318. // The GUI
  319. procedure SideButtonStyle(Obj: TFormObject);
  320. begin
  321.   TButtonObject(Obj).SetDefaultStyles();
  322.   Obj^.Styles.Padding     := [5,5,5,6];
  323.   Obj^.Styles.BorderSize  := 0;
  324.   Obj^.Styles.BorderColor := SlackGUI.Palette[clBackground4];
  325.   Obj^.Styles.Background  := SlackGUI.Palette[clBackground0];
  326.   Obj^.Styles.FontSize    := 8;
  327.  
  328.   Obj^.Styles2.Background := SlackGUI.Palette[clHighlighted2];
  329.   Obj^.Styles2.BorderColor:= SlackGUI.Palette[clHighlighted2];
  330.   Obj^.Styles2.FontSize   := Obj^.Styles.FontSize;
  331.   Obj^.Styles2.FontColor  := SlackGUI.Palette[clBackground0];
  332.   Obj^.Styles2.Padding    := Obj^.Styles.Padding;
  333. end;
  334.  
  335. procedure OnCloseWindow(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  336. begin
  337.   SlackGUI.Form.Close();
  338. end;
  339.  
  340. procedure OnDeleteNodeBtn(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  341. begin
  342.   DeleteNode(InFocus);
  343.   InFocus := High(Graph.Nodes);
  344. end;
  345.  
  346. procedure OnPrintBtn(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  347. begin
  348.   Write('Index(',InFocus,'), ');
  349.   Write('Node(', Graph.Nodes[InFocus],'), ');
  350.   Write('Paths(', Graph.Paths[InFocus],')');
  351.   WriteLn();
  352. end;
  353.  
  354. procedure OnCopyBtn(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  355. var s: string;
  356. begin
  357.   s := 'Graph.Nodes := '+ ToString(Graph.Nodes) + ';';
  358.   s += #13#10;
  359.   s += 'Graph.Paths := '+ ToStr(Graph.Paths) + ';';
  360.   SetClipBoard(s);
  361. end;
  362.  
  363. procedure OnRunTest(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  364. begin
  365.   IsTesting := not IsTesting;
  366.   if IsTesting then
  367.   begin
  368.     TestPath := [];
  369.     Sender^.Styles.BorderColor := SlackGUI.Palette[clBackground0];
  370.     Sender^.Styles.Background  := SlackGUI.Palette[clHighlighted2];
  371.     Sender^.Styles.FontColor   := SlackGUI.Palette[clBackground0];
  372.     Sender^.Styles2.Background := SlackGUI.Palette[clHighlighted2];
  373.     Sender^.Styles2.FontColor  := SlackGUI.Palette[clBackground0];
  374.   end else
  375.   begin
  376.     SideButtonStyle(Sender);
  377.     Swap(Sender^.Styles, Sender^.Styles2);
  378.   end;
  379. end;
  380.  
  381. procedure OnRunCheck(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  382. var count,node,i,j:Int32;
  383. begin
  384.   for i:=0 to High(Graph.Paths) do
  385.     for j:=0 to High(Graph.Paths[i]) do
  386.     begin
  387.       node := Graph.Paths[i][j];
  388.       if not InIntArray(Graph.Paths[node], i) then
  389.       begin
  390.         Graph.Paths[node] += i;
  391.         Inc(count);
  392.       end;
  393.     end;
  394.   if count <> 0 then
  395.     WriteLn('Check completed: Fixed `', count,'` pathways!')
  396.   else
  397.     WriteLn('Check completed: All was good!');
  398. end;
  399.  
  400. procedure OnPrintSep(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  401. begin
  402.   WriteLn(#13#10);
  403. end;
  404.  
  405. procedure DrawMap(Self: TFormObject);
  406. var
  407.   newW, newH, X,Y,W,H,i,j: Int32;
  408.   p,q: TPoint;
  409.   tmp: TBitmap;
  410.   muf: TMufasaBitmap;
  411.   B: TRect;
  412.   tmpTPA,line: TPointArray;
  413. begin
  414.   SlackGUI.RenderBasicBlock(Self);
  415.  
  416.   with self.Bounds do
  417.   begin
  418.     X := Left + 5;
  419.     Y := Top  + 5;
  420.     W := Right  - X - 5;
  421.     H := Bottom - Y - 5;
  422.   end;
  423.  
  424.   muf := WorldImg.Copy(CurrX,CurrY, Min(WorldImg.GetWidth,CurrX+W)-1,Min(WorldImg.GetHeight, CurrY+H)-1);
  425.   muf.SetList(client.GetMBitmaps);
  426.   client.GetMBitmaps.AddBMP(muf);
  427.   DrawWeb(muf, CurrX, CurrY, Graph);
  428.  
  429.   if (IsTesting) and (Length(TestPath) > 0) then
  430.     DrawPath(muf, CurrX, CurrY, TestPath, Graph);
  431.  
  432.   tmp := muf.ToTBitmap;
  433.   SlackGUI.Canvas.Draw(x,y,tmp);
  434.   tmp.Free();
  435.   muf.Free();
  436. end;
  437.  
  438.  
  439. procedure ImgPress(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  440. var
  441.   dx,dy,idx: Int32;
  442. begin
  443.   if Button = mbLeft then
  444.   begin
  445.     tmpX := X;
  446.     tmpY := Y;
  447.     startX := CurrX;
  448.     startY := CurrY;
  449.  
  450.     if (InFocus <> -1) then
  451.       with Sender.Bounds(True) do
  452.       begin
  453.         dx := CurrX + X - Left;
  454.         dy := CurrY + Y - Top;
  455.         if Distance(Graph.Nodes[InFocus], Point(dx-5,dy-5)) < 5 then
  456.           IsDraggingNode := True;
  457.       end;
  458.  
  459.     if(not IsDraggingNode) then
  460.       IsDragging := True;
  461.   end;
  462. end;
  463.  
  464. procedure ImgMove(Sender: TFormObject; Shift: TShiftState; X,Y: Int32); static;
  465. begin
  466.   if IsDragging then
  467.   begin
  468.     CurrX := Max(0, CurrX + tmpX-X);
  469.     CurrY := Max(0, CurrY + tmpY-Y);
  470.     tmpX := X;
  471.     tmpY := Y;
  472.   end;
  473.  
  474.   if IsDraggingNode then
  475.     with Sender.Bounds(True) do
  476.       Graph.Nodes[InFocus] := Point(CurrX + X - Left, CurrY + Y - Top);
  477. end;
  478.  
  479. procedure ImgRelease(Sender: TFormObject; Button: TMouseButton; Shift: TShiftState; X,Y: Int32); static;
  480. var
  481.   dx,dy,c,idx: Int32;
  482.   DidChange: Boolean;
  483.   t: Double;
  484. begin
  485.   if (Button = mbLeft) and (IsDragging) then
  486.   begin
  487.     CurrX := Max(0, CurrX + tmpX-X);
  488.     CurrY := Max(0, CurrY + tmpY-Y);
  489.     IsDragging := False;
  490.     DidChange := (StartX <> CurrX) or (StartY <> CurrY);
  491.   end else
  492.   if (Button = mbLeft) and (IsDraggingNode) then
  493.   begin
  494.     with Sender.Bounds(True) do
  495.       Graph.Nodes[InFocus] := Point(CurrX + X - Left, CurrY + Y - Top);
  496.     IsDraggingNode := False;
  497.     Exit;
  498.   end;
  499.  
  500.   if (Button = mbLeft) and (not DidChange) then
  501.     with Sender.Bounds(True) do
  502.     begin
  503.       dx := CurrX + X - Left - 5;
  504.       dy := CurrY + Y - Top - 5;
  505.  
  506.       idx := CheckForNearbyNode([dx,dy]);
  507.  
  508.       if IsTesting then
  509.       begin
  510.         if idx <> -1 then
  511.         begin
  512.           t := PerformanceTimer();
  513.           TestPath := FindPath(Graph, InFocus, idx);
  514.           WriteLn('Path generated in ', Round(PerformanceTimer - t),'ms | Found ', Length(TestPath), ' nodes');
  515.         end;
  516.         Exit;
  517.       end;
  518.  
  519.       if (idx = -1) then                   // add node
  520.         AddNode(Point(dx,dy))
  521.       else if (not(ssShift in Shift)) then // select node
  522.         InFocus := idx
  523.       else if (InFocus <> idx) then        // connect node
  524.         ConnectNodes(InFocus, idx);
  525.     end;
  526. end;
  527.  
  528. procedure TSlackGUI.Init(); static; override;
  529. var
  530.   TitleBar, TopObject, Button, MapPath: TFormObject;
  531.   W, H: Int32;
  532. begin
  533.   SlackGUI.Width  := 990;
  534.   SlackGUI.Height := 620;
  535.   SlackGUI.Palette := DARK_NEUTRAL;
  536.  
  537.   inherited;
  538.  
  539.   W := SlackGUI.Width;
  540.   H := SlackGUI.Height;
  541.  
  542.   with (TopObject := SlackGUI.AddObject(FormObject('Stub')))^ do
  543.   begin
  544.     Position   := bpRelative;
  545.     Styles.Background  := SlackGUI.Palette[clBackground2];
  546.     Styles.BorderColor := SlackGUI.Palette[clBorder1];
  547.     Styles.BorderSize  := 0;
  548.     Styles.Padding     := [];
  549.     RenderProc := @RenderBasicBlock;
  550.   end;
  551.  
  552.   with TTitlebarObject(TitleBar := SlackGUI.AddObject(TitlebarObject('TitleBar', [0,0,W,29], TopObject)))^ do
  553.   begin
  554.     Text       := 'Web Walk Generator';
  555.     RenderProc := @RenderTitlebar;
  556.  
  557.     Styles.Background  := $1F1A13;
  558.     Styles.BorderColor := SlackGUI.Palette[clBorder1];
  559.     Styles.BorderSize  := 0;
  560.     Styles.FontStyle := [fsBold];
  561.     Styles.FontColor := SlackGUI.Palette[clText1];
  562.     Styles.FontSize  := 12;
  563.     Styles.FontName  := 'Tahoma';
  564.   end;
  565.  
  566.   with TButtonObject(SlackGUI.AddObject(ButtonObject('GUIClose', TitleBar.Bounds, TitleBar)))^ do
  567.   begin
  568.     Bounds := Rect(Bounds.Right-26, Bounds.Top, Bounds.Right, Bounds.Bottom);
  569.     Text   := 'X';
  570.     Styles.FontName   := 'MS Sans Serif';
  571.     Styles.Background := SlackGUI.Palette[clBackground0];
  572.     Styles.BorderSize := 0;
  573.     Styles.FontSize   := 13;
  574.     Styles.FontStyle  := [fsBold];
  575.     Styles.FontColor  := SlackGUI.Palette[clText3];
  576.     Styles.Padding    := [7,5,0,0];
  577.  
  578.     Styles2 := Styles;
  579.     Styles2.Background := clRed;
  580.     Styles2.FontColor  := SlackGUI.Palette[clText1];
  581.  
  582.     RenderProc := @RenderTextButton;
  583.     OnClick    := @OnCloseWindow;
  584.   end;
  585.  
  586.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('REMOVE', [10,40,65], TopObject)))^ do
  587.   begin
  588.     RenderProc := @RenderTextButton;
  589.     SideButtonStyle(Button);
  590.     Text := 'REMOVE';
  591.     OnClick := @OnDeleteNodeBtn;
  592.   end;
  593.  
  594.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('COPY', [10,65,65], TopObject)))^ do
  595.   begin
  596.     RenderProc := @RenderTextButton;
  597.     SideButtonStyle(Button);
  598.     Text := 'COPY';
  599.     OnClick := @OnCopyBtn;
  600.   end;
  601.  
  602.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('TEST', [10,90,65], TopObject)))^ do
  603.   begin
  604.     RenderProc := @RenderTextButton;
  605.     SideButtonStyle(Button);
  606.     Text := 'TEST';
  607.     OnClick := @OnRunTest;
  608.   end;
  609.  
  610.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('CHECK', [10,115,65], TopObject)))^ do
  611.   begin
  612.     RenderProc := @RenderTextButton;
  613.     SideButtonStyle(Button);
  614.     Text := 'CHECK';
  615.     OnClick := @OnRunCheck;
  616.   end;
  617.  
  618.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('PRINT', [10,200,65], TopObject)))^ do
  619.   begin
  620.     RenderProc := @RenderTextButton;
  621.     SideButtonStyle(Button);
  622.     Text := 'PRINT';
  623.     OnClick := @OnPrintBtn;
  624.   end;
  625.  
  626.   with TButtonObject(Button := SlackGUI.AddObject(ButtonObject('SEPARATOR', [10,225,65], TopObject)))^ do
  627.   begin
  628.     RenderProc := @RenderTextButton;
  629.     SideButtonStyle(Button);
  630.     Text := '---------';
  631.     OnClick := @OnPrintSep;
  632.   end;
  633.  
  634.   with (MapPath := SlackGUI.AddObject(FormObject('MapPath', [65,40,-10,-10], TopObject)))^ do
  635.   begin
  636.     Position := bpRelative;
  637.     Styles.Background  := SlackGUI.Palette[clBackground2];
  638.     Styles.BorderColor := SlackGUI.Palette[clBorder1];
  639.     Styles.BorderSize  := 0;
  640.     Styles.Padding := [];
  641.     RenderProc := @RenderBasicBlock;
  642.  
  643.     with SlackGUI.AddObject(FormObject('Image''includes/RSWalker/maps/World.png');
  644.   SlackGUI.Show();
  645.   WorldImg.Free();
  646. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement