/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ //////////////////////////////////////////////////// // // Button functions // //////////////////////////////////////////////////// HeldButton* HeldButton::Add(const HeldButton& item) { HeldButton* pItem = new HeldButton(item); item.window->menuItems.push_back(pItem); item.window->AddTabbing(pItem); return pItem; } // Updates the button bool HeldButton::Update() { if (!PositivePressed()) this->status = 0; int status; // We don't care as much if the cursor isn't being pressed if (PositiveTriggered()) status = 2; else status = 1; // See if we just hit something if (CursorColliding(this->x, this->y, this->width, this->height)) { if (status > this->status) this->status = status; // Held buttons behave slightly differently! if (this->status == 2 && (CursorTime() == 0 || (CursorTime() >= 30 && (CursorTime() - 30) % 5 == 0))) this->func(this->funcExtra); } else if (this->status == 1) this->status = 0; return (this->status == 0); } // Draws the button void HeldButton::Draw() { CVec4 color = colorFunc(status); if (tex) DrawTexQuad(*tex, position, size, color); else DrawBox(position, size, color); if (text.text[0]) DrawTextCenter(text.text, CVec3(x, y, z + 0.0001), CVec2(width, height * 0.8), CVec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b)); } // Resets the button's status void HeldButton::Reset() { if (this->status > 0) this->status = 0; }