Results 1 to 8 of 8

Thread: Interactive Paint User Interface [Early Development]

  1. #1
    Join Date
    May 2012
    Posts
    16
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default Interactive Paint User Interface [Early Development]

    The Interactive Paint User Interface is inspired by the "rsbuddy" client but with this interface you will be able to take advantage of the powerful SRL while playing the game.

    My goal is to make a [API] in the script that allows you to add widgets to the interface. The widgets would be able to paint reports and perform procedures that are assigned to the widget. For example a PVP Widget could enable a auto Switcher with a GUI that is fully customizable (paths,mousSpeed,clickSpeed,etc)

    Current Features [beta]
    r - toggles mouse control
    e - toggles paint control ( clicking on paint icon toggles paint tools. Iv'e only made one tool that changes the color of the lines )



    Code:
    program InteractiveSmart;
    {$DEFINE SMART}
    {$i AeroLib/AeroLib.Simba}
    const
     clGray2 = 3157549;
     clGray3 = 8618892;
    
    
    type _object = record
      shape : string;
      cords : Tbox;
      color : integer;
    end;
    
    type texture = record
      bitmap: integer;
      draw : array of _object;
    end;
    type dimensions = record
      width,height: integer;
    end;
    
    
    
    type button = record
      dimension: dimensions;
      posRange: Tpoint;
      typeButton: integer;
      active:boolean;
      texture : texture;
    end;
    
    
    type iconBitmap = record
      width,height,scale,onStatus,offStatus:integer;
    
    end;
    
    
    type bar = record
      name :string;
      font : string;
      height : integer;
      color : integer;
      textColor : integer;
    end;
    
    type icon = record
      boxCords : Tbox;
      dimensions : dimensions;
    end;
    
    type widget = record
      icon: icon;
      inputCall: string;
      window_dimensions:dimensions;
      windowSpawnPoint:TPoint;
      titleBar: bar;
      button: array of button;
    end;
    
    type cWidget = record
      _on : boolean;
      widget : ^widget;
    end;
    
    
     var
      clickSpeed:integer;
      isSmartOn:boolean;
      lastpoint2painted: TPoint;
      point1pb,Point2pb,pointpb: Tpoint;
      UI_topBar: iconBitmap;
      mouseBitmap: iconBitmap;
      paintBitmap: iconBitmap;
      UI_Combat:iconBitmap;
      clientW, clientH: integer;
      slotx1,slotx2,sloty1,sloty2: integer;
      xSlotOffset: integer;
      rainBow : boolean;
      UI_topBar_font : Tfont;
      Widget_WindowBar_font : Tfont;
      currentWidget : cWidget;
      smallWindow :dimensions;
      slimWindow : dimensions;
      defaultButtonSize: dimensions;
      defaultSpawnPoint : TPoint;
      defaulttitleheight : integer;
      defaultPosRange: TPoint;
      singleButton : integer;
      smallBox : Tbox;
      widgetArra: array of ^widget;
    
      //////////////// Widget Decleration ///////////////////////
      pvpWidget, paintWidget: widget;
    
    
    procedure declareBitmaps;
    begin
      mouseBitmap.onStatus := BitmapFromString(23, 30, 'meJztVVlPE1EUrkZKEbpASxegdE' +
            'r3aTtdqEIoUGhEE1wSBQ0xEYh/w2gMibIjIoWQ+iARSkJAJKBBwoM' +
            'SSVCjiSY++OQDj7Ygmy3t0OuZXgoIoQGevfkymTnzzXe/Ofeec62U' +
            '2WahTKRBwOOmcpL1GvV5d/nli5Xu0pJsmYTHTaNMRitlTgxQUMjlo' +
            'nRBc2Mj2jee9vVmpAssZlNiEVKvcxYW4E8GB57XVF1VEUQKO4nUaS' +
            'fGRiD4bmaKz+XCXAlEpOJMrCCTZCYnnSJy5aRBB1PrtRoWizXsG4R' +
            'Xt+vrdBp1YjNZUmm+1ZJHEHarZXfcaDBUuMtAZMQ3AOKJzUBWtWoV' +
            'KABNr9MCH5woFbknWaybN6pB5MuHeXAl4HKNBr06TwkwG8k9M2LIJ' +
            'GJg6jWq6qprIFtXW/vkcSdCNKLDUTo85PP1eLqLCguuXKoscRaJhR' +
            'knWCyYeseehUpN4dTX3VpeWcH5ASfevl7mbjOCQmsoHMRxt8v1ce4' +
            '9E96kZ6anKCMJKcW/AAa+ff28taibG3ABt20tTcxjcA1t/EGhdeaK' +
            'wqVO5+vxlzEejek116sV8hzAm8mJLT6QAQjBBmtvbWaC+HMAYybiK' +
            'i6OiUS3lOkQUNQqJbPE4BkeMfnwInFy88MHmSJhzFcU/iQGxicsWG' +
            'dHW9w2jgMBgcj0q0n823Gg/mf9MqlkKRAI+P0Y/l/+9dUV2DMN9+8' +
            'tLy1uxwGLfn++zToy5FsK7AR/B/zdXV0mkrSaTbABtkEZja6S4rMO' +
            'h8lI7o4DExbXbrPCBtghkwbYlMKM9P11d6Qx9mJULBYxdzhLxwBCH' +
            'o9HggsQko8TflQg1NvT819kv4g4M746xxXxer1M7YRDiD6+k5bmJn' +
            'l21qf5uX9q7fCAwkfIYbdB61ApiK20HEknttN+/vguTBfgxthw904' +
            'sM+uH1YF2FythsUiETze7lUpmszta44dXcPVAqVB8lthQ5REqJbHd' +
            'paFPnk7hnLFZFhYW4oUFnWpjZ+kjQRSN4K4CY3x0GJqqZnejxjoWC' +
            'g4LPo97oeLc7OzbTZreX7Ch4Nqj9naNkuClHXhGgyy8AikOOymDzy' +
            'N1mtJip7vc7S4rK3DYCXlOSjKbz02Dw3HPh38B/I5PnA==');
    
      mouseBitmap.offStatus := BitmapFromString(23, 30, 'meJztVV1TEmEU/hE2Ggou3wssu4' +
            'AKlpo16XXlpCkqIihoH2QzOU0zFcnCfvDhLsuCsoiNWdnUTZf9vR7' +
            'YMlOH0utmnoud85593nPOe85z/AztZ2jGS1nNJsLU63GRoWBw9PpI' +
            'cHDQabdYCKOP9vrbPp3hctqt5v6Z6bCi7NXrHzTtY73+UdM+7eweR' +
            'haWbVbirzxej3toYECSG1++fo8tJ8bHbrhJR7/R4HW7VmJrh4ff1p' +
            'JPLISpMwmiKBZ3ymXNbjH39xnAwFAeXA3y3p4ry9HEbv3D5O1Jr8f' +
            'VgQT+4PHRtMflPHXEeD3DweC2VI9FEyDvHAyq6vWQfoYBaAqldYDZ' +
            'QzqMhu6b47cKherGxoveq11WwghPHAP4CPiYc/My9HRRbnJ89AZim' +
            'Lg9EVmK85yczZZyue3VlfVIJD4YCIyN4OEGbJZ+Y2836naSAeWYnJ' +
            'jIbBVwb2PvM7JbXIjWaocct82yRfBIUr1caSK7VOp5WdnL56sP1zc' +
            'Qr9NmaadAI4Bnz17Wau8Foaz7I9qZ6VlBqLBsAZYsW2xRcRKaJ5F4' +
            'JAgKx0moVUXdHx+7iQ5BxZLJx7LcYNueAEhQkwczc6KoZrOtMHTke' +
            'Dk0NAQSnm/dpUfYaBxRLqfDZuFy0rHnv5PoEMXK9P05h828XdrlOJ' +
            'nnW8jlJPStj6ZmH4TRPzwv6faWQ74CkuTak3xe1Y0AvqNLK6TDyrK' +
            'lt1tCOt3C2zRfyKtukpy6dz+bk9Jp8ad9S8hk8njWWDSJaHUjwGZL' +
            '4blFmqJwLyqJZ/0Fdyg4NIgfflt+ItQ2n7FTdivR0D7VagfVE8Do1' +
            'XbeV/80AmeNWuMosfrIaTcLfPn4aS4KFHk+vATREAXluNoXBXpmYT' +
            '76n+QsCTq2IKr6IFwCeJ3IYhyzc+kwsu3ZwbxjkJ+mNnleuUQw+AW' +
            'DFvC3ehhyp6r7mKAL8cBZzFc2N1/ZLYQujHfvTKnqO70J/5EBClYq' +
            '7aIaGD1dHgmTAak19o5EUclkCh2o9CNZ1uRyEwvi1I6AzPoZ35vXH' +
            'NZfoViDAEKfT/4OqYGAKEqzWj1Yja8buqHq5ywjSCWW78i1a6nUJv' +
            'JFtJDNstIEJEkDM8KYnZuHHnbe0Thyk3Zkh+3spdzYDtdDw8OhUMD' +
            'vwzsSpj4rYcJyPPXXD5GEKmI=');
    
    
    
      paintBitmap.onStatus := BitmapFromString(26, 30, 'meJylVmtMFFcU9m9bo+77ObPLPm' +
            'd379w7O9KiUKqIRWytomJf8dFWba3P1qq1VqEq4qNNVcRYfBR8BRM' +
            'FYxWBFhWbNAGj2IBG4otYIbHyQzBBYolsv2V0WAX9481kc+bMud89' +
            '5zuPuxIVpZd7/F7PuHfGzp87V/B5XxKKBAOhgBCJRLZs/tkd53yxM' +
            'SUhnBgU/Ewkfb9CadRpW1pagHapocFqNqq7XE5HnIOP3RXw+zyuuN' +
            'mzZk6amGE2GhycHW7EouGg6dOmRp6sgM8HJWycHHdg//7ykycdnE0' +
            'BhHLUyBGRmFVRXp6clGSzmHG0gobTS0tLVIOctWvEUBAOqJrt+flK' +
            '+LAsKTkS6bN+r6zk7Ta43WPD/XbsmPqpsrLCYjTU19ermu7ubr1WA' +
            '/dwxKaNG6G5f/++y8EXFRXGYr6ZONzrjkOkM6ZPU5Ub1ucmJyUq8t' +
            '6iIkV4b9y7MAPCsqVL8ProUbdBqwFp2H6xrk7dmzY6FbUBZ06fPoX' +
            'XP8+eBbfb8vKUrwMGDGhvb4fQ3Nw8aOBrXrfrzp070WRdauBsVsQF' +
            'TnSawbnrclTAeDkMJZgc+OorVrMJEdXU1EB/4vhxo14398s5fYmam' +
            'DFB8PsERryM+BmxWsxzvvhc+ZSaMhLujU0fc+hQ8aSMCSiku3fvQr' +
            '8uJwdEWUzGosJefrq6uj7+6EOkI0DJYk94Mx/+ziVRKgJw9Q/ZMHC' +
            'jqHhOoehkWZmT5/57+BDyV4sW+jxuuOqwmKSA8H7m5MRhCSa9DgTC' +
            'n+XucAEn5/HyDk7e4AzDSTDZ0FAPMnmb9VxtLRBu3Lhht5rhAORFC' +
            '3vQ3C45PV2anClYzGgZpfA8jOx0xG/lw1sdMp5Cu8woAYkwQOGBtJ' +
            'aWZiB0dnYitNbWVshr16z2cLb4zCmjOrpGtXcmrlhJPW6lRH2M/Oi' +
            'U8/koFNwr4GX4BkClhoHw4MEDhRmTQV934QKEQ8XFTqM+ISs75d97' +
            'KS2tSYX76JMWRtclEhGR7ubkPXY5LRQFUpvLbNCrPAPt4MEDEJpu3' +
            'kTlUI8rqfhwclmlxCgLBXsHBUU2xbcIDcIh+lT7x6IZ9doF8+cpMn' +
            'JHQ0HqdFD0vhCUfEQK9W6MckWjAT4zRmLRDDqt2qTfr1iBio3aBAl' +
            'LpXQxZYliLGC/z1OR6nVIyt8XL0Z6+lGnGRLNY0AkexnZQekuSXKT' +
            'fidbL5rREMtbwOf9YMoU5RXTGK5KfkJ+ZaSAke0MaJL4It+Q046OD' +
            'hUNRyPef27dUjRoSVEIsmGiOEtksigRcOWjLI7RQL9oaE+lm1C3yK' +
            'MyGFH5ClpjY6Nm8CAGugQCKEo9bwhTR7h3yaEUBRB16xO9fpRhDwM' +
            'gqqnpJja2tbVZTY8nOXpk44b1CiA6TgtAEV6FJJGlc1fTHDVvO/4S' +
            'GQeoBHHoT+Gla9gC1AtsEItC++3bt4Gs3hcYktVnziiAZWUn4CGcZ' +
            'lRI5y+N4etS48pExguif7k0+xeWtUtaPZVOCIkBzOHq6uiuhvp6zm' +
            'qJvYCQ0wvnzyuA165ddXJ2t8seJsOH+7+W4AkNYXsmHbtPyt0rrUu' +
            'mCXAVc+Po0dJIz7QE8jM3ml4zpOqPKjXpC+bN02oGejw2Sh5nISD6' +
            'k+jrYUKdLh6DAjfdnj27YVlaUgLkvlckUpydlaUCtt279+2ypTgXx' +
            'YBfMGyxGE0mff62vOysVeBqfW4uzHYWFAC53zsXM3BoWGq8ciUSsz' +
            'DhT1VVVVSUX758WdFcv34d5Cz5ZjFkYEZr9bl/CQR0Ssb48efO1Ua' +
            'es3AcKnbWzM8g40ryPRli/T5wEvem3WpBdJ9+MmPrli1HDh8+WlqK' +
            'sbNq5UpcMShdDBWYpY0eHWYU8v8Ns7Cm');
    
    
    
            paintBitmap.offStatus :=   BitmapFromString(25, 30, 'meJylVmlTGlkU/SMzo0DTO0sQRV' +
            'BERCCCRDQKCihoAu4LuNDsKPsiEiWLxorl/NI5TVcsM+P4JVWvqNf' +
            'd95137zl3QatWaX9j8SxtMU9MT02rOPZ3cNQ8p9WoioV6KLTO0uTr' +
            'xriLZxn8alT8f79SSkUsuttuf0kmC0r54BM+TSoYUvlkhrO0kjCPj' +
            'U3b7IaRYZxiaeo5oJpnjQZDo3FdKl3W659GhvR4yTG0XqeLRnfXI1' +
            'FKKZdw8DIUjLTbX1utz7Xap0z6wutdYGgSTkqAHEO9X/DhU6nUxq/' +
            'fH8Sr0ZGRfL4G/Kur2ymrTTLmGfriol2pdIrFRrXardevm80eApkY' +
            'NwNEI/JNLgKqLkJVq1c720d4E48L8BCPtVp3c3NfCoRlKEEogoeF+' +
            'UWn/e3paRbuwaxSufLOzYMKEDhmNNYbN7gOt6z4Q+MmEx6BHIvuAe' +
            'r8vNmXmAE5iePUZeebZ/Yd9ljYtJo9eIiD79/7aJLAy1AoDKj9vQQ' +
            'O+JcC+HR6lmNo5cVFC/tgMKzVqJ12J/wElHncLCmIsyajMZerIqhW' +
            '+4vT4USQQJAP/kERchjs7cVb7c+roXXZwJ/BQARR4JZcroJAGo2bk' +
            '+OUiuM4luGRFRxLkYRhWJ/NlhH4vHcR5BiGhyOR2NSkFdel0+eQye' +
            'l4C8lw73EiDccAWK11j4/TojM06ZywFGM7pa1dh9kMNDAPGxxhSML' +
            'tmu31Hna2D3H2/LxxefkV+SNGwXOkQmYaHUUtDA8NkYQcOWE2GL4L' +
            'ud5JuneSuk8XR/VDlJKAFg6bHQbh8AfA5nMVhXwAWotQIARZzdBWp' +
            '9NgHEW+ikWhVjEsE3B7bpO5T4lkN352n8r7ZlwsS+OrTqshFXIQDr' +
            'HKlQ4k+BmgkyHkHv9y9u7x7PqryTSm7pcnaHJPWu+EvAT1I1OcHh/' +
            'n+ypgKRUykAB1yuUOJDg8PAWHS4vLStlAJHGa7N3m7v+2zbjgoZT2' +
            'LMscBlcfc6XHfPkouMo/q0elYkBInUMgKPVGo15dFVUDICEffKPVx' +
            'DIF/4eY+md1SGgURQ5pNSM6nZIknpehUv4TqnwFKNeMC6JDfexFuq' +
            'A7Q7MkhfVr8XKqPnvPF6BSfSgEiMfhIR10Rw477GLK4Ti49qy4fVs' +
            '+Dc+/2Ft+8UooPgXIUORxIgVBpdxQMcz0rC3zI5t+yPq2ffDtNSjF' +
            'YEqCKndwL0dTs24PCh+dAfXIUpTFOZG+z2QecvOReY6iJLH+B0qWS' +
            'KQkBVWcGBGKV0gWwNhZsoBqAlcOr/1dyKPmOKQEuhDMkBdPKojIKn' +
            'GPvDo4OAE55fIlQxFi8tAU+jygkBV+XwAVytE0R1JiHmo0a8s7fm8' +
            'YVhIIw5BiA+SZfkOWb2/tIyJASQ1ZNKDISPgjGGu2ejNOF90XnWPI' +
            '4GKsnLrHcjvmIQr8Pw0fNg9KVtNEv/kRG+uxRvOmUKgRz3o7viTiS' +
            'aChv3ncczBDt/S6l2vZh5JwNzXhgD9uq/NOuLlLXQuROE0r4X8oEE' +
            'ZaQkfw9rzto6Iz6VK9fgMml/0hUVCOeWvzTFsc/bxiDTp9N17/nro' +
            'JuJdYlsJdCwuLnc63o8Mz1OC/RpVWrU6nL8RIm72jo7M34JaQIRJN' +
            'n3bEPKrXT41Z4BKaEgJxzcx2u3dbmwcYTy8NPvrjh21IACGQIdHoj' +
            'nXSilhALEUoFLK/KFKBNrWxsUnIBuw2e+fqdm1tAwYvzly0diR/Pl' +
            'ftoyFeseejCcRiu0gk9CXwiYXjkxYLoHxLKwj2xdwT5cPc4fllX0A' +
            'QCoCCTOjncBUkY4/BJySLYANDp335bc7jRSyv1IVGHJvikDIZTZ7Z' +
            'ueDKGmYuYkELFachS0t/OcZNYzot/jvw/wAKQpXZ');
    
    
    end;
    
    
    procedure setup_UI_Settings;
    begin
      getClientDimensions(clientW,clientH);
      UI_topBar.width := clientW - 2;
      UI_topBar.height := round(clientH * 0.045);
      slotX1 := round(UI_topBar.width * 0.125);
      slotY1 := round(UI_topBar.height * 0.2);
      slotX2 := slotx1 + round(UI_topBar.width * 0.02);
      slotY2 := round(UI_topBar.height * 0.8);
      xslotOffset := slotx2 - slotx1;
    
      //UI_ICON_Settings
      resizeBitmapex(mouseBitmap.onStatus, RM_Bilinear, slotx2-slotx1, sloty2-sloty1);
      resizeBitmapex(mouseBitmap.offStatus, RM_Nearest, slotx2-slotx1, sloty2-sloty1);
      resizeBitmapex(paintBitmap.onStatus, RM_Nearest, round((slotx2-slotx1) *1.2), sloty2-sloty1);
      resizeBitmapex(paintBitmap.offStatus, RM_Nearest, round((slotx2-slotx1) *1.2), sloty2-sloty1);
      //Button Types
      singleButton := 1;
    
      //default window settings
      slimWindow.width := round(0.1 * clientw);
      slimWindow.height := round(0.4 * clientH);
      smallwindow.width := round( 0.4 * clientw);
      smallWindow.height := round( 0.4 * (clientH - UI_Topbar.height));
      defaultSpawnPoint  := point(0,UI_topBar.height);
      defaultTitleHeight := round( 0.07 * smallWindow.height );
      //default button settings
      defaultButtonSize.width := round(clientW*0.02);
      defaultButtonSize.height := round(clientH*0.02);
      defaultPosRange :=  point(0,UI_topBar.height + defaultTitleHeight);
    end;
    
    function to_Object(shape:string; cords:Tbox; color:integer): _Object;
    var
      obj : _Object;
    begin
      obj.shape := shape;
      obj.color := color;
      obj.cords := cords;
      result := obj;
    end;
    
    
    procedure drawObjects(_object: _object);
    begin
      if ( lowerCase(_object.shape) = 'box' ) then
      begin
        os_smart.__Graphics.DrawBox(_object.cords.x1 ,_object.cords.y1 , _object.cords.x2, _object.cords.y2,false,_object.color);
      end;
    end;
    
    procedure setupFont;
    begin
      widget_windowBar_font.Init;
      widget_windowBar_font.setName('Arial');
      widget_windowBar_font.setSize(round(defaulttitleHeight * 0.6));
      LoadSystemFont(widget_windowBar_font,'w_titleBar');
    
      UI_topBar_font.Init;
      UI_topBar_font.setName('Arial');
      UI_topBar_font.setSize(round(UI_topBar.height * 0.5));
      LoadSystemFont(UI_topBar_font,'UI_TitleBar');
    end;
    
    
    procedure paint_UIIcon(icon:string; status:boolean);
    begin
    
    
      if (icon = 'mouse') then
      begin
        if ( status = true ) then
        begin
          os_smart.__Graphics.DrawBitmap(mouseBitmap.onStatus,point(slotx1,sloty1),false);
        end else
          os_smart.__graphics.DrawBitmap(mouseBitmap.offStatus,point(slotx1,sloty1),false);
      end else if ( icon = 'paint' ) then
      begin
        if ( status = true ) then
        begin
          os_smart.__graphics.DrawBitmap(paintBitmap.onStatus,point(slotx2 + xslotOffset,sloty1),false);
        end else
          os_smart.__graphics.DrawBitmap(paintBitmap.offStatus,point(slotx2 + xslotOffset,sloty1),false);
      end else if ( icon = 'combat') then
      begin
        if ( status = true ) then
        begin
          os_smart.__Graphics.DrawBitmap(UI_Combat.onStatus,point(slotx2 + xslotOffset*15,sloty1),false);
        end else
          os_smart.__Graphics.DrawBitmap(UI_Combat.offStatus,point(slotx2 + xslotOffset*15,sloty1),false);
      end;
    
    
    end;
    
    function smartSetAsTarget(pid: Int32): boolean;
    begin
      result := true;
    
      try
        setEIOSTarget('libsmartremote', intToStr(pid));
        //print('smartSetAsTarget(): Succesfully set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
      except
        //print('smartSetAsTarget(): Failed to set SMART['+ intToStr(pid) +'] as Simba''s target', TDebug.SUB);
        result := false;
      end;
    end;
    
    
    procedure smartOn(true:boolean);
    begin
      if ( true ) and not ( isSmartOn ) then
      begin
        isSmartOn := true;
        writeln('Turning Smart On');
        smartSetAsTarget(OS_SMART.__PID);
        me.name := 'r';
        me.pass := 'r';
        me.Active := true;
      end else if not (true) and ( isSmartOn ) then
      begin
        isSmartOn := false;
        writeln('Turning Smart Off');
        setDeskTopAsClient;
      end;
    end;
    
    function mouseOnScreen(paint:boolean; var point:Tpoint ):boolean;
    begin
      result := false;
      point := getRealMousePnt;
    
      if ( paint = true) then
      begin
        result:= true;
        if ( point.x > 3 ) and ( point.x < clientW -4)  and ( point.y > UI_topBar.height + 3 ) and ( point.y < clientH -4 ) then
          exit;
        if ( point.x > clientw-4) then
          point.x := clientw-4;
        if (point.y > clienth-4) then
          point.y := clienth-4;
        if (point.x < 3) then
          point.x := 3;
        if (point.y < UI_topBar.height + 3 ) then
          point.y := UI_topBar.height + 3;
      end else if ( point.x > 0 ) and ( point.x < clientW)  and ( point.y > 0 ) and ( point.y < clientH ) then
      begin
        result := true;
      end;
    end;
    
    
    
    function mousePressed(fast:boolean):boolean;
    var
      time: timer;
      speed: integer;
      q :integer;
    begin
      speed := 40;
      if ( fast ) then
        speed := 20;
    
      smartOn(false);
      if ( isMouseButtonDown(MOUSE_LEFT) ) then
      begin
        result := true;
        time.start;
        repeat
          wait(50);
        until  not ( isMouseButtonDown(MOUSE_LEFT) );
      end;
    
    end;
    
    
    function KeyPressed(key:char):boolean;
    var
      time:timer;
    begin
    
      smartOn(false);
      if ( isKeyDown(getKeyCode(key)) ) then
      begin
        result := true;
        time.start;
        repeat
        until ( time.timeElapsed >= (clickSpeed * 100) ) or not ( isKeyDown(getKeyCode(key)) );
      end;
    
    end;
    
    
    procedure paintIcon(icon:string);
    var
      bitmap:integer;
      iconPoint: TPoint;
    begin
      smartOn(true);
      os_smart.__Graphics.ClearArea(0,0,100,100);
      lowerCase(icon);
    
      iconPoint := point(20,20);
    
      Case icon of
        'mouse': begin
                      bitmap := mouseBitmap.onStatus;
                      os_smart.__Graphics.DrawBitmap(bitmap,iconPoint,false);
                 end;
        'paint': begin
                      bitmap := paintBitmap.onStatus;
                      OS_SMART.__Graphics.DrawBitmap(bitmap,iconPoint,false);
                 end;
      end;
      smartOn(false);
    
    end;
    
    
    function isMouseMoved(currentPoint2:Tpoint):boolean;
    begin
      result := true;
      if ( currentPoint2.x = lastPoint2Painted.x ) and ( currentPoint2.y = lastPoint2Painted.y ) then
        result := false;
      lastPoint2Painted := currentPoint2;
    
    end;
    
    procedure controlMouse;
    var
      KMTarget, ITarget : Integer;
      mousePoint:tpoint;
      i:integer;
      initPos: boolean;
    begin
      if not ( keyPressed('r') ) then
        exit;
      wait(5);
      smartOn(false);
      initPos := true;
      paint_UIICON('mouse',true);
      writeln('Control Mouse - [ON]');
      repeat
        if (mouseONScreen(false,mousePoint) ) then
        begin
          if (mousePressed(true)) then
          begin
            smartclickmouse(os_smart.Target,mousepoint.x,mousepoint.y,MOUSE_LEFT);
          end;
          if ( isMouseMoved(mousePoint) ) then
          begin
            inc(i);
            smartMovemouse(OS_smart.target,mousePoint.x,mousePoint.y);
          end;
        end;
      wait(5);
      until (keypressed('r'));
      paint_UIIcon('mouse',false);
      writeln('Control Mouse - [OFF]');
    end;
    
    
    procedure drawInterface;
    begin
      os_smart.__Graphics.DrawBox(200,200,300,300,true,clred);
    end;
    
    function randomColor: integer;
    var
      colorArray: array of integer;
    begin
      colorArray := [clRed,clWhite,clPink,clAqua,clOrange,clLime,clYellow];
      result := colorArray[randomRange(0,length(colorArray)-1)];
    end;
    procedure paintBoxGuide(var point1:Tpoint; var point2:Tpoint);
    var
      color: integer;
    begin
      color := clRed;
      if ( rainbow ) then
        color := randomColor;
     // OS_smart.__Graphics.DrawLine(
      os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clientH -1);
      OS_SMART.__Graphics.DrawLine(point1,point(point2.x,point1.y),color,false); //top horizontal line
      OS_SMART.__Graphics.DrawLine(point1,point(point1.x,point2.y),color,false);  //left  vertical line
      OS_SMART.__graphics.DrawLine(point(point2.x,point1.y),point2,color,false); // right vertical line
      OS_SMART.__Graphics.DrawLine(point(point1.x,point2.y),point2,color,false); // bottom horizonal line
    end;
    
    
    procedure paintBox2;
    var
      mouseClicks: integer;
      mousePoint: TPoint;
      point1: TPoint;
      tempPoint2: TPoint;
    begin
      if not ( keyPressed('e') ) then
        exit;
      currentWidget._on := false;
      paint_UIIcon('paint',true);
      os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clienth -1); //change const
      repeat
        //statusBar := 'Paint Activated';
        if ( mousePressed(false) ) then
        begin
          if ( ( mouseClicks = 0 ) or ( mouseClicks = 2 ) ) and ( mouseOnScreen(true,mousePoint) ) then
          begin
            if ( mouseClicks = 2 ) then
            begin
              os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clienth -1); //change const
              mouseClicks := 0;
            end;
            inc(mouseClicks);
            point1 := mousePoint;
          end else if ( mouseClicks = 1 ) and ( mouseOnScreen(true,mousePoint) ) then
          begin
            inc(mouseClicks);
            paintBoxGuide(point1,mousePoint);
            writeln(point1,mousePoint);
          end;
        end else if ( mouseclicks = 1 ) and ( mouseOnScreen(true,mousePoint) ) and ( isMouseMoved(mousePoint) ) then
        begin
          paintBoxGuide(point1,mousePoint);
          os_smart.__Graphics.DrawCircle(mousePoint,2,clRed,true);
        end;
      wait(50);
      until ( keyPressed('e') );
      paint_UIIcon('paint',false);
      os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clienth -1); //change const
    end;
    
    
    procedure freeBitmaps;
    begin
      freeBitmap(paintBitmap.onStatus);
      freeBitmap(mouseBitmap.onStatus);
      freeBitmap(UI_combat.onStatus);
      freeBitmap(paintBitmap.offStatus);
      freeBitmap(mouseBitmap.offStatus);
    
    end;
    
    
    procedure paintUI;      //clearTfont*(*(*(*(*(
    begin
      //UI_TopBar
      os_smart.__Graphics.DrawBox(0,0,UI_topbar.width,UI_topBar.height,true,clGray2);
      OS_SMART.__Graphics.DrawClippedText('BETA', 'UI_TitleBar' ,intToPoint(round(clientW * 0.025),round(clientH * 0.008)),clGray3);
    
       //UI ICONS
       paint_UIIcon('mouse',false);
       paint_UIICON('paint',false);
       //paint_UIIcon('combat',false);
    end;
    
    var
      combatON:boolean;
    procedure mouseOnCombat;
    var
      point: TPoint;
    begin
      mouseOnScreen(false,point);
      if (  point.x > slotx2 + (slotx2-slotx1)*15 ) and ( point.x < slotx2 + (slotx2-slotx1)*15 + round(slotx2-slotx1) *4 ) and (point.y < UI_topBar.height ) and ( point.y > 0 ) and (mousePressed(false)) then
      begin
        if not (combatON) then
        begin
          paint_UIIcon('combat',true);
          OS_SMART.__Graphics.DrawClippedText('COMBAT MODE ACTIVATED', smallChars ,intToPoint(100,100),clred);
          combatON := true;
        end else
        begin
          paint_UIIcon('combat',false);
          os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clienth -1);
          combatON := false;
        end;
      end;
    end;
    
    
    function slotCords(slot : integer):Tbox;
    begin
      result := toBox(slotx1 + (xslotOffset * slot),sloty1,slotx2 + (xslotOffset * slot),sloty2);
    end;
    
    
    
    
    procedure setupWidgets;
    begin
    
           { Widget  Settings }
    
    ////////////////  PVP_WIDGET  //////////////////
      //widget Main Window dimensions
      pvpWidget.window_dimensions := slimWindow;
      //widget title bar settings(font/name)
      pvpWidget.titleBar.name := 'PVP';
      pvpWidget.titleBar.font := 'w_titleBar';
      pvpWidget.titleBar.height := defaultTitleHeight;
      //Widget spawnPoint
      pvpWidget.windowSpawnPoint := defaultSpawnPoint;
      pvpWidget.inputCall := 'key';
    
    
      setLength(pvpWidget.button,1);
      pvpWidget.button[0].typeButton := singleButton;
      pvpWidget.button[0].dimension := defaultButtonSize;
      pvpWidget.button[0].posRange := defaultPosRange;
      pvpWidget.icon.boxCords := slotCords(1);
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    
    ///////////PAINT_WIDGET///////////// //////////
    paintWidget.inputCall := 'iconPressed';
    paintWidget.window_dimensions := slimWindow;
    paintWidget.windowSpawnPoint := defaultSpawnPoint;
    paintWidget.titleBar.height := defaultTitleHeight;
    paintWidget.titleBar.name := 'Paint Settings';
    paintWidget.titleBar.font := 'w_titleBar';
    paintWidget.titleBar.color := clGray2;
    paintWidget.titleBar.textColor := clGray3;
    ////paintButtons....
    setLength(paintWidget.button,1);
    paintwidget.button[0].dimension := defaultButtonSize;
    paintWIdget.button[0].posRange := defaultPosRange;
    paintWIdget.button[0].typeButton := singleButton;
    setlength(paintWidget.button[0].texture.draw,1);
    paintWidget.button[0].texture.draw[0] := to_object('box',toBox(paintWidget.button[0].posRange.x + round(paintWidget.button[0].dimension.width * 0.25)  , paintWidget.button[0].posRange.y + round( paintWidget.button[0].dimension.height * 0.25) ,round(paintWidget.button[0].posRange.x + paintWidget.button[0].dimension.width * 0.75), round(paintWidget.button[0].posRange.y + paintWidget.button[0].dimension.height * 0.75)),clRed);
    ////iconCords....
    paintWidget.icon.boxCords := slotCords(2);
    /////////////////////////////////////////////////////////
    end;
    
    procedure addWidget(var widget:widget);
    begin
      setlength(widgetArra,length(widgetArra)+1);
      widgetArra[length(widgetArra)-1] := @Widget;
    end;
    
    procedure initWidgets;
    begin
      addWidget(paintWidget);
    end;
    
    procedure paintWidgets(widget:widget);
    var
      x,y:extended;
      text: string;
      i,q: integer;
    begin
      x := ( widget.window_dimensions.width * 0.5 ) -  2 * (length(widget.titleBar.name) + 6 );
      y := 0.1;
      os_smart.__Graphics.DrawBox(widget.windowSpawnPoint.x,widget.windowSpawnPoint.y,widget.window_dimensions.width, widget.windowSpawnPoint.y + widget.titleBar.height,true,widget.titleBar.color );
      os_smart.__graphics.DrawBox(0,widget.windowSpawnPoint.y + widget.titleBar.height, widget.window_dimensions.width,widget.window_dimensions.height,true,clgray2 );
      OS_SMART.__Graphics.DrawClippedText(widget.titleBar.name, widget.titleBar.font ,intToPoint(round(x),round(widget.titleBar.height*y)+widget.windowSpawnPoint.y),widget.titleBar.textColor);
      OS_Smart.__Graphics.DrawLine(point(widget.windowSpawnPoint.x,widget.windowSpawnPoint.y), point(widget.window_dimensions.width,widget.windowSpawnPoint.y),clgray3); /// hardCode..**
      os_smart.__graphics.DrawLine(point(widget.windowSpawnPoint.x,widget.windowSpawnPoint.y + widget.titleBar.height), point(widget.window_dimensions.width + widget.windowSpawnPoint.x ,widget.windowSpawnPoint.y + widget.titleBar.height),clGray3); /// hardCode..**
      for i:= 0 to length(widget.button)-1 do
      begin
        os_smart.__graphics.DrawBox(widget.button[i].posRange.x ,widget.button[i].posRange.y ,widget.button[i].posRange.x + widget.button[i].dimension.width, widget.button[i].posRange.y + widget.button[0].dimension.height ,false,clgray);
        for q := 0 to ( length(widget.button[i].texture.draw) -1 ) do
        begin
          drawObjects(widget.button[i].texture.draw[q]);
        end;
      end;
    end;
    
    procedure findWidgetSpace;
    begin
    
    end;
    
    procedure printGrid;
    var
      i: integer;
      w,h: extended;
    begin
      w:= 0.4;
      h:= 0.4;
      for i := 1 to 2 do
      begin
        os_smart.__Graphics.DrawLine(point(round((clientw-4)*w*i),UI_topbar.height ),point(round(w*(clientw-4)*i),(clienth-4)));
        os_smart.__Graphics.DrawLine(point(0,round((clienth-4)*h*i)),point((clientw-4),round((clientH-4)*h*i)));
    
      end;
    end;
    
    
    procedure buttonsize;
    var
      button : button;
      deltaBox : Tbox;
      x,y : extended;
    begin
      x := 0.02;
      y := 0.03;
      deltaBox := tobox(0,0,round(clientW*0.02),  round(clientH*0.03) );
      os_smart.__Graphics.DrawBoxes([deltaBox]);
      // print array of boxes of any size. only boxes that fit will be printed
    end;
    
    
    
     procedure widgetActive;
     begin
    
     end;
    
     var
      tempPoint: Tpoint;
      q: integer;
    
    procedure turnWidgetOn();
    begin
      paintWidgets(currentWidget.widget^);
    end;
    
    function isPointOnWidget(var widget: ^widget; var point: TPoint): boolean;
    var
      i: integer;
    begin
      result := false;
      if  ( point.x > widget^.icon.boxCords.x1 ) and ( point.x < widget^.icon.boxCords.x2 ) and ( point.y > widget^.icon.boxCords.y1 ) and ( point.y < widget^.icon.boxCords.y2 ) then
      begin
        result := true;
      end;
    end;
    
    procedure checkWidgets(var mousePoint : Tpoint);
    var
      i:integer;
    begin
      for i:= 0 to ( length(widgetArra) - 1 ) do
      begin
        if ( isPointOnWidget(widgetArra[i],mousePoint) ) then
        begin
          if ( currentWidget._On ) then
          begin
            currentWidget._On := false;
            os_smart.__Graphics.ClearArea(0,UI_topBar.height,clientw-1,clientH -1);
          end else
          begin
            currentWidget._On := true;
            currentWidget.widget := widgetArra[i];
            turnWidgetOn;
          end;
        end;
      end;
    
    end;
    
     //Key Storage Options
    //sort widget.key in the keyArray when widget is added   //keyArray[24+2(mouse)]
    
    procedure checkWidgetButton(var mousePoint :Tpoint);
    var
      i:integer;
    begin
      for i := 0 to length( currentWidget.widget^.button ) - 1 do
      begin
        if ( mousePoint.x > currentwidget.widget^.button[i].posRange.x ) and ( mousePoint.y > currentWidget.widget^.button[i].posRange.y ) and ( mousePoint.x < currentWidget.widget^.button[i].posRange.x + currentWidget.widget^.button[i].dimension.width ) and ( mousePoint.y <  currentWidget.widget^.button[i].posRange.y + currentWidget.widget^.button[0].dimension.height ) then
        begin
          if not ( rainBow ) then
          begin
            os_smart.__Graphics.ClearArea(100,100,100 + round(length('COMBAT MODE ACTIVATED')*11) ,145);
            OS_SMART.__Graphics.DrawClippedText('RainBow Mode [ON]', charsnpc ,intToPoint(100,100),clred);
            currentWidget.widget^.button[i].active := true;
            rainBow := true;
          end else
          begin
            os_smart.__Graphics.ClearArea(100,100,100 + round(length('COMBAT MODE ACTIVATED')*11) ,145);
            OS_SMART.__Graphics.DrawClippedText('RainBow Mode [OFF]', charsnpc ,intToPoint(100,100),clred);
            currentWidget.widget^.button[i].active := false;
            rainBow := false;
          end;
        end;
      end;
    end;
    
    
    begin
      OS_SMART.Create(900, 638, SMART_UserAgent, ['']);
      OS_SMART.ClearScreen;
      declareBitmaps;
      setup_UI_settings;
      setupFont;
      paintUI;
      isSmartOn := true;
      clickSpeed := 5;
      setupWidgets;
      initWidgets;
      writeln(paintWidget.button[0].texture.draw[0].shape);
    
      repeat
      controlMouse;
      paintBox2;
      if ( keyPressed('p') ) then
        break;
      wait(50);
      if ( mouseOnScreen(false,tempPoint) ) and ( mousePressed(false) ) then
      begin
        writeln('mouseClick');
        writeln(tempPOint);
        checkWidgets(tempPoint);
        if (currentWidget._On ) then
        begin
          checkWidgetButton(tempPoint);
        end;
      end;
      until false;
    
      freebitmaps;
    end.

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Ooh, this is interesting. How (if at all) does it relate to something like this?

    Juding from your post, you're using keypresses to toggle features on/off. Hotkeys would probably work better for the most commonly-used features, but eventually you'll need a form or GUI to keep track of them all, akin to OSBuddy's settings interface.

    Painting that form on SMART would be super badass.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    This looks really interesting, I look forward to seeing it progress.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  4. #4
    Join Date
    Aug 2015
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    Ooh, this is interesting. How (if at all) does it relate to something like this?

    Juding from your post, you're using keypresses to toggle features on/off. Hotkeys would probably work better for the most commonly-used features, but eventually you'll need a form or GUI to keep track of them all, akin to OSBuddy's settings interface.

    Painting that form on SMART would be super badass.
    I totally agree with KeepBotting on this one... I think a working gui in smart while it runs has been a long time coming as well.
    THaToNeGUyWItHThEfAcE

  5. #5
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Why would you need a interact-able GUI though? If people don't mind me asking..





  6. #6
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Fitta View Post
    Why would you need a interact-able GUI though? If people don't mind me asking..
    Changing options during runtime, rather than having to restart the whole script because you forgot to flip a boolean.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  7. #7
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    To attach to SMART without any plugins.. Try the below for example..

    Now if the form does not attach to SMART, drag the crosshairs over SMART's window. Copy the number in the debug box: "New Window: SomeNumberHere".. and replace "GetNativeWindow()" with that number.. "MainForm.setParentWindow(ThatNumberHere);"..

    That will attach the form to SMART.


    It seems that whenever SMART is loaded, GetNativeWindow is broken. Probably because SMART is overriding Simba's target. Also, if you uncomment the alpha-blend to make it semi-transparent.. It will NOT show for some odd reason.


    EDIT: Came up with a workaround for GetNativeWindow().. Not need to drag the cross-hairs either..


    Simba Code:
    {$DEFINE SMART}
    {$I SRL-6/SRL.Simba}

    const
      clSkyBlue = 15780518;

    var
      MainForm: TForm;
      ControlPanel: TGroupBox;
      ToggleButton: TButton;
      CloseButton: TButton;

      bool: Boolean;


    procedure ToggleClicked(Sender: TObject); native;
    begin
      bool := not bool;
    end;

    procedure OnClose(Sender: TObject); native;
    begin
      MainForm.setEnabled(false);
      MainForm.Close();
    end;


    procedure InitForm; native;
    var
      Rect: TRect;
    begin
      MainForm.Init(nil);
      CloseButton.Init(MainForm);
      ControlPanel.Init(MainForm);
      ToggleButton.Init(MainForm);

      with MainForm do
        begin
          setBorderStyle(bsNone);
          setActiveControl(CloseButton);
          setCaption('Title');
          setBounds(1, 600 - 129, 798, 128);
          setColor(clSkyBlue);
          setAlphaBlendValue(200);
          //setAlphaBlend(true);
        end;

      with ControlPanel do
        begin
          setParent(MainForm);
          setBounds(8, 5, 781, 117);
          setCaption('Control Panel');
        end;

      with ToggleButton do
        begin
          setParent(MainForm);
          setCaption('Toggle Boolean');
          setBounds(100, 90, 100, 22);
          setOnClick(ToggleClicked);
      end;

      with CloseButton do
        begin
          SetParent(MainForm);
          setBounds(775, 0, 23, 21);
          setCaption('X');
          setOnClick(OnClose);
        end;

      MainForm.ShowOnTop();
    end;

    procedure DestroyForm; native;
    begin
      if (MainForm <> nil) then
      begin
        MainForm.Free();
        MainForm := nil;
      end;
    end;

    procedure killfrm;
    begin
      if (MainForm <> nil) then
        MainForm.Close();

      sync(DestroyForm);
    end;

    {$IFDEF SMART}
    //Work around to get SMART's Window Handle =]
    //Uses Internal API/Variables. Maybe SRL-6 should officially add something like this..
    Function GetNativeWindow(): Integer; override;
    var
      I: Integer;
      Processes: TSysProcArr;
    begin
      Result := 0;
      Processes := GetProcesses();
      For I := 0 to High(Processes) Do
        If (Processes[I].Pid = __smartCurrentPid) Then
        Begin
          SetTarget(Processes[i]);
          Result := inherited();
          setEIOSTarget('libsmartremote', intToStr(__smartCurrentPid));
          Break;
        End;
    End;
    {$ENDIF}

    begin
      SetupSRL;

      sync(InitForm);
      addOnTerminate('killfrm');

      MainForm.setParentWindow(GetNativeWindow());

      while(MainForm.isEnabled()) do
      begin
        writeln(bool);
        Sleep(100);
      end;

      sync(DestroyForm);
    end.

    Once you run it, the form should automatically attach to SMART =]
    @thoth; See the above. No need for a plugin.
    Last edited by Brandon; 08-31-2015 at 07:25 PM.
    I am Ggzz..
    Hackintosher

  8. #8
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by thatOneGuyWithTheFace View Post
    I totally agree with KeepBotting on this one... I think a working gui in smart while it runs has been a long time coming as well.
    Quote Originally Posted by KeepBotting View Post
    Changing options during runtime, rather than having to restart the whole script because you forgot to flip a boolean.
    I'm a staunch advocate of ezForm, which I believe is beginning to fill this role, it would be nice if it's eventually officially supported! It's pretty cool.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •