123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2013 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- ConsoleMethodGroupBeginWithDocs(Scroller, SpriteBase)
- /*! Sets the number of times to repeat the texture over x direction
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setRepeatX, ConsoleVoid, 3, 3, (repeatX))
- {
- object->setRepeatX( dAtof(argv[2]) );
- }
- //------------------------------------------------------------------------------
- /*! Sets the number of times to repeat the texture in y direction.
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setRepeatY, ConsoleVoid, 3, 3, (repeatY))
- {
- object->setRepeatY( dAtof(argv[2]) );
- }
- //------------------------------------------------------------------------------
- /*! @return Returns repeat X value
- */
- ConsoleMethodWithDocs(Scroller, getRepeatX, ConsoleFloat, 2, 2, ())
- {
- return object->getRepeatX();
- }
- //------------------------------------------------------------------------------
- /*! @return Returns repeat Y value
- */
- ConsoleMethodWithDocs(Scroller, getRepeatY, ConsoleFloat, 2, 2, ())
- {
- return object->getRepeatY();
- }
- //------------------------------------------------------------------------------
- /*! Sets the scroll speed in x direction
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollX, ConsoleVoid, 3, 3, (ScrollX))
- {
- object->setScroll(dAtof(argv[2]), object->getScrollY());
- }
- //------------------------------------------------------------------------------
- /*! Sets the scroll speed in the Y direction
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollY, ConsoleVoid, 3, 3, (ScrollY))
- {
- object->setScroll(object->getScrollX(), dAtof(argv[2]));
- }
- //------------------------------------------------------------------------------
- /*! @return Returns Scroll speed in x direction.
- */
- ConsoleMethodWithDocs(Scroller, getScrollX, ConsoleFloat, 2, 2, ())
- {
- return object->getScrollX();
- }
- //------------------------------------------------------------------------------
- /*! @return Returns Scroll speed in y direction.
- */
- ConsoleMethodWithDocs(Scroller, getScrollY, ConsoleFloat, 2, 2, ())
- {
- return object->getScrollY();
- }
- //------------------------------------------------------------------------------
- /*! Set the texture's position in x direction
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollPositionX, ConsoleVoid, 3, 3, (ScrollPositionX))
- {
- object->setScrollPosition(dAtof(argv[2]), object->getScrollPositionY());
- }
- //------------------------------------------------------------------------------
- /*! Set the texture's position in y direction
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollPositionY, ConsoleVoid, 3, 3, (ScrollPositionY))
- {
- object->setScrollPosition(object->getScrollPositionX(), dAtof(argv[2]));
- }
- //------------------------------------------------------------------------------
- /*! Returns texture's position in x direction
- */
- ConsoleMethodWithDocs(Scroller, getScrollPositionX, ConsoleFloat, 2, 2, ())
- {
- return object->getScrollPositionX();
- }
- //------------------------------------------------------------------------------
- /*! Returns texture's position in y direction
- */
- ConsoleMethodWithDocs(Scroller, getScrollPositionY, ConsoleFloat, 2, 2, ())
- {
- return object->getScrollPositionY();
- }
- //------------------------------------------------------------------------------
- /*! Sets the Repeat X/Y repetition in each direction.
- @param repeatX/Y The number of times to repeat in each direction as either (\x y\ or (x, y)
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setRepeat, ConsoleVoid, 3, 4, (float repeatX / float repeatY))
- {
- // The new position.
- F32 repeatX;
- F32 repeatY;
- // Elements in the first argument.
- U32 elementCount = Utility::mGetStringElementCount(argv[2]);
- // ("repeatX repeatY")
- if ((elementCount == 2) && (argc == 3))
- {
- repeatX = dAtof(Utility::mGetStringElement(argv[2], 0));
- repeatY = dAtof(Utility::mGetStringElement(argv[2], 1));
- }
- // (repeatX, repeatY)
- else if ((elementCount == 1) && (argc == 4))
- {
- repeatX = dAtof(argv[2]);
- repeatY = dAtof(argv[3]);
- }
- // Invalid
- else
- {
- Con::warnf("Scroller::setRepeat() - Invalid number of parameters!");
- return;
- }
- // Set Repeat.
- object->setRepeat(repeatX, repeatY);
- }
- //------------------------------------------------------------------------------
- /*! Sets the Scroll speed.
- @param offsetX/Y The scroll speed in each direction as either (\x y\ or (x, y)
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScroll, ConsoleVoid, 3, 4, (offsetX / offsetY))
- {
- // The new position.
- F32 scrollX;
- F32 scrollY;
- // Elements in the first argument.
- U32 elementCount = Utility::mGetStringElementCount(argv[2]);
- // ("scrollX scrollY")
- if ((elementCount == 2) && (argc == 3))
- {
- scrollX = dAtof(Utility::mGetStringElement(argv[2], 0));
- scrollY = dAtof(Utility::mGetStringElement(argv[2], 1));
- }
- // (scrollX, scrollY)
- else if ((elementCount == 1) && (argc == 4))
- {
- scrollX = dAtof(argv[2]);
- scrollY = dAtof(argv[3]);
- }
- // Invalid
- else
- {
- Con::warnf("Scroller::setScroll() - Invalid number of parameters!");
- return;
- }
- // Set Scroll.
- object->setScroll(scrollX, scrollY);
- }
- //------------------------------------------------------------------------------
- /*! Sets Auto-Pan Polarwise.
- @param angle Polar angle.
- @param scrollSpeed Speed as polar magnitude
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollPolar, ConsoleVoid, 4, 4, (angle, scrollSpeed))
- {
- // Renormalise Angle.
- F32 angle = mFmod(dAtof(argv[2]), 360.0f);
- // Fetch Speed.
- F32 scrollSpeed = dAtof(argv[3]);
- // Set Scroll.
- object->setScroll( mCos(mDegToRad(angle))*scrollSpeed, mSin(mDegToRad(angle))*scrollSpeed );
- }
- //------------------------------------------------------------------------------
- /*! Sets the Scroll position X/Y.
- @param positionX/Y The scroll texture position as either (\x y\ or (x, y)
- @return No return value.
- */
- ConsoleMethodWithDocs(Scroller, setScrollPosition, ConsoleVoid, 3, 4, (positionX / positionY))
- {
- // The new position.
- F32 scrollX;
- F32 scrollY;
- // Elements in the first argument.
- U32 elementCount = Utility::mGetStringElementCount(argv[2]);
- // ("positionX positionY")
- if ((elementCount == 2) && (argc == 3))
- {
- scrollX = dAtof(Utility::mGetStringElement(argv[2], 0));
- scrollY = dAtof(Utility::mGetStringElement(argv[2], 1));
- }
- // (positionX, positionY)
- else if ((elementCount == 1) && (argc == 4))
- {
- scrollX = dAtof(argv[2]);
- scrollY = dAtof(argv[3]);
- }
- // Invalid
- else
- {
- Con::warnf("Scroller::setScrollPosition() - Invalid number of parameters!");
- return;
- }
- // Set Scroll Position.
- object->setScrollPosition(scrollX, scrollY);
- }
- ConsoleMethodGroupEndWithDocs(Scroller)
|