google-site-verification: googlebaca44933768a824.html Gui - A slider - Old Royal Hack Forum

Announcement

Collapse
No announcement yet.

Gui - A slider

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Gui - A slider

    I have a mouse implemented GUI and I have no idea how to do slider controls.. how would I even start coding a slider control for my gui to control lets say rgb values (individually)

    like:

    Code:
    hook.m_pNeeded->FillRGBA(x,y,w,h,sliderR.value,sliderG.value.,sliderB.value..)
    Hm.. I can draw the slider just need to get the slider to stop at 255.

    #2
    if(kk < 255)
    // now u are able to increase value if kk is less then 255
    I 0x90 you!

    Comment


      #3
      This is how i do my Sliders in CoD4 and in various other games, but its not game dependant. As long as your not a complete idiot you can figure it out.

      Length is the length of the slider, fMouseX and fMouseY are store the current mouse location returned from GetCursorPos.

      The only bit you need from below is the math calculations.

      PHP Code:
      void DrawSlider(float PosXfloat PosYfloat Length,  float MinNumfloat MaxNumfloat &Variable)
      {
          
      float Scale MaxNum/Length;

          
      // Draw Line at PosX, PosY with the width of Length.

          // My Amazing Mathematical skills!!!
          
      if ( fMouseX >= ( PosX ) && fMouseX <= ( PosX Length ) && fMouseY >= ( PosY ) && fMouseY <= ( PosY ) && GetAsyncKeyStateVK_LBUTTON ) )
              
      Variable MinNum + (fMouseX PosX) * Scale;

          
      // Draw Vertical line (Slider itself at PosX + (Variable/Scale) )
          
      //    sprintf(Text, TEXT("%1.0f"),Variable);
      //    Draw Value of Text where ever you want....

      Comment


        #4
        It's called interpolation, and it's been around for millennia.

        interpolatedValue = (currentPosition / maxValue) * maxPosition;

        The parenthesis aren't needed in C/C++, but are in Java / ECMAScript. Wierd huh?

        Comment

        Working...
        X