diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-12-22 16:51:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-12-22 16:51:26 +0300 |
commit | 908c8cf42783133861d734dc0de1b170d9507564 (patch) | |
tree | 7af7038b3c0ef393ba91ce1b3106bc4927890fcd /src | |
parent | 8e5f09c54a7c48e24f2c5be073c75b4f93b5fd15 (diff) | |
download | ManaVerse-908c8cf42783133861d734dc0de1b170d9507564.tar.gz ManaVerse-908c8cf42783133861d734dc0de1b170d9507564.tar.bz2 ManaVerse-908c8cf42783133861d734dc0de1b170d9507564.tar.xz ManaVerse-908c8cf42783133861d734dc0de1b170d9507564.zip |
Add restrict keyword to touchmanager.
Diffstat (limited to 'src')
-rw-r--r-- | src/touchmanager.cpp | 50 | ||||
-rw-r--r-- | src/touchmanager.h | 76 |
2 files changed, 66 insertions, 60 deletions
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 11e514634..6b84fa9b0 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -77,12 +77,12 @@ TouchManager::~TouchManager() CHECKLISTENERS } -void TouchManager::shutdown() +void TouchManager::shutdown() restrict { config.removeListeners(this); } -void TouchManager::init() +void TouchManager::init() restrict { config.addListener("showScreenJoystick", this); config.addListener("showScreenButtons", this); @@ -110,19 +110,19 @@ void TouchManager::init() mHeight = mainGraphics->mHeight; } -void TouchManager::loadTouchItem(TouchItem **item, - const std::string &name, - const std::string &imageName, - const std::string &text, +void TouchManager::loadTouchItem(TouchItem **restrict item, + const std::string &restrict name, + const std::string &restrict imageName, + const std::string &restrict text, int x, int y, const int width, const int height, const int type, - const std::string &eventPressed, - const std::string &eventReleased, + const std::string &restrict eventPressed, + const std::string &restrict eventReleased, const TouchFuncPtr fAll, const TouchFuncPtr fPressed, const TouchFuncPtr fReleased, - const TouchFuncPtr fOut) + const TouchFuncPtr fOut) restrict { *item = nullptr; if (!theme) @@ -185,7 +185,7 @@ void TouchManager::loadTouchItem(TouchItem **item, mRedraw = true; } -void TouchManager::clear() +void TouchManager::clear() restrict { FOR_EACH (TouchItemVectorCIter, it, mObjects) unload(*it); @@ -193,7 +193,7 @@ void TouchManager::clear() mRedraw = true; } -void TouchManager::draw() +void TouchManager::draw() restrict { if (mRedraw) { @@ -222,7 +222,7 @@ void TouchManager::draw() drawText(); } -void TouchManager::safeDraw() +void TouchManager::safeDraw() restrict { FOR_EACH (TouchItemVectorCIter, it, mObjects) { @@ -244,7 +244,7 @@ void TouchManager::safeDraw() drawText(); } -void TouchManager::drawText() +void TouchManager::drawText() restrict { if (!gui) return; @@ -271,7 +271,7 @@ void TouchManager::drawText() } } -bool TouchManager::processEvent(const MouseInput &mouseInput) +bool TouchManager::processEvent(const MouseInput &mouseInput) restrict { const int x = mouseInput.getTouchX(); const int y = mouseInput.getTouchY(); @@ -325,7 +325,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) return false; } -bool TouchManager::isActionActive(const InputActionT index) const +bool TouchManager::isActionActive(const InputActionT index) restrict const { if (static_cast<int>(index) < 0 || static_cast<int>(index) >= actionsSize) @@ -335,7 +335,7 @@ bool TouchManager::isActionActive(const InputActionT index) const return mActions[static_cast<size_t>(index)]; } -void TouchManager::resize(const int width, const int height) +void TouchManager::resize(const int width, const int height) restrict { mRedraw = true; const int maxHeight = mHeight; @@ -373,7 +373,7 @@ void TouchManager::resize(const int width, const int height) mHeight = mainGraphics->mHeight; } -void TouchManager::unload(TouchItem *const item) +void TouchManager::unload(TouchItem *restrict const item) { if (item) { @@ -391,7 +391,7 @@ void TouchManager::unload(TouchItem *const item) } } -void TouchManager::unloadTouchItem(TouchItem **unloadItem) +void TouchManager::unloadTouchItem(TouchItem *restrict *unloadItem) restrict { FOR_EACH (TouchItemVectorIter, it, mObjects) { @@ -405,14 +405,14 @@ void TouchManager::unloadTouchItem(TouchItem **unloadItem) } } -void TouchManager::loadPad() +void TouchManager::loadPad() restrict { const int sz = (mJoystickSize + 2) * 50; loadTouchItem(&mPad, "dpad.xml", "dpad_image.xml", "", -1, -1, sz, sz, LEFT, "", "", &padEvents, &padClick, &padUp, &padOut); } -void TouchManager::loadButtons() +void TouchManager::loadButtons() restrict { const int sz = (mButtonsSize + 1) * 50; if (!theme) @@ -570,13 +570,13 @@ void TouchManager::loadButtons() } } -void TouchManager::loadKeyboard() +void TouchManager::loadKeyboard() restrict { loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", "", -1, -1, 28, 28, NORMAL, "", "screenActionKeyboard"); } -void TouchManager::optionChanged(const std::string &value) +void TouchManager::optionChanged(const std::string &value) restrict { if (value == "showScreenJoystick") { @@ -654,21 +654,21 @@ void TouchManager::optionChanged(const std::string &value) } } -void TouchManager::setInGame(const bool b) +void TouchManager::setInGame(const bool b) restrict { mInGame = b; mShow = mInGame && !mTempHideButtons; mRedraw = true; } -void TouchManager::setTempHide(const bool b) +void TouchManager::setTempHide(const bool b) restrict { mTempHideButtons = b; mShow = mInGame && !mTempHideButtons; mRedraw = true; } -void TouchManager::executeAction(const std::string &event) +void TouchManager::executeAction(const std::string &restrict event) { inputManager.executeAction(static_cast<InputActionT>( config.getIntValue(event))); diff --git a/src/touchmanager.h b/src/touchmanager.h index e3bb93798..99d904765 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -36,7 +36,7 @@ class ImageCollection; class ImageRect; class MouseInput; -typedef void (*TouchFuncPtr) (const MouseInput &mouseInput); +typedef void (*TouchFuncPtr) (const MouseInput &restrict mouseInput); const int actionsSize = static_cast<int>(InputAction::TOTAL); const int buttonsCount = 12; @@ -44,13 +44,18 @@ const int buttonsCount = 12; struct TouchItem final { TouchItem(const std::string &text0, - const Rect &rect0, const int type0, - const std::string &eventPressed0, - const std::string &eventReleased0, - ImageRect *const images0, Image *const icon0, - const int x0, const int y0, const int width0, const int height0, - const TouchFuncPtr ptrAll, const TouchFuncPtr ptrPressed, - const TouchFuncPtr ptrReleased, const TouchFuncPtr ptrOut) : + const Rect &rect0, + const int type0, + const std::string &restrict eventPressed0, + const std::string &restrict eventReleased0, + ImageRect *restrict const images0, + Image *restrict const icon0, + const int x0, const int y0, + const int width0, const int height0, + const TouchFuncPtr ptrAll, + const TouchFuncPtr ptrPressed, + const TouchFuncPtr ptrReleased, + const TouchFuncPtr ptrOut) : text(text0), rect(rect0), type(type0), @@ -108,36 +113,37 @@ class TouchManager final : public ConfigListener RIGHT = 2 }; - void init(); + void init() restrict; - void loadTouchItem(TouchItem **item, - const std::string &name, - const std::string &imageName, - const std::string &text, + void loadTouchItem(TouchItem **restrict item, + const std::string &restrict name, + const std::string &restrict imageName, + const std::string &restrict text, int x, int y, const int width, const int height, const int type, - const std::string &eventPressed, - const std::string &eventReleased, + const std::string &restrict eventPressed, + const std::string &restrict eventReleased, const TouchFuncPtr fAll = nullptr, const TouchFuncPtr fPressed = nullptr, const TouchFuncPtr fReleased = nullptr, - const TouchFuncPtr fOut = nullptr) A_NONNULL(2); + const TouchFuncPtr fOut = nullptr) + restrict A_NONNULL(2); - void clear(); + void clear() restrict; - void draw(); + void draw() restrict; - void safeDraw(); + void safeDraw() restrict; - void drawText(); + void drawText() restrict; - bool processEvent(const MouseInput &mouseInput); + bool processEvent(const MouseInput &mouseInput) restrict; - bool isActionActive(const InputActionT index) const; + bool isActionActive(const InputActionT index) restrict const; void setActionActive(const InputActionT index, - const bool value) + const bool value) restrict { if (static_cast<int>(index) >= 0 && static_cast<int>(index) < actionsSize) @@ -146,30 +152,30 @@ class TouchManager final : public ConfigListener } } - void resize(const int width, const int height); + void resize(const int width, const int height) restrict; - static void unload(TouchItem *const item); + static void unload(TouchItem *restrict const item); - void unloadTouchItem(TouchItem **unloadItem); + void unloadTouchItem(TouchItem *restrict *unloadItem) restrict; - void optionChanged(const std::string &value) override final; + void optionChanged(const std::string &value) restrict override final; - void loadPad(); + void loadPad() restrict; - void loadButtons(); + void loadButtons() restrict; - void loadKeyboard(); + void loadKeyboard() restrict; - int getPadSize() const + int getPadSize() restrict const { return (mJoystickSize + 2) * 50; } - void setInGame(const bool b); + void setInGame(const bool b) restrict; - void setTempHide(const bool b); + void setTempHide(const bool b) restrict; - void shutdown(); + void shutdown() restrict; - static void executeAction(const std::string &event); + static void executeAction(const std::string &restrict event); private: TouchItem *mKeyboard; |