/*---------------------------------------------------------------------------* 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 // //////////////////////////////////////////////////// Button* Button::Add(const Button& item) { Button* pItem = new Button(item); item.window->menuItems.push_back(pItem); item.window->AddTabbing(pItem); return pItem; } // Updates the button bool Button::Update() { int status; // We don't care as much if the cursor isn't being triggered if (PositiveTriggered()) status = 2; else status = 1; // See if we just hit something if (CursorColliding(this->x, this->y, this->width, this->height)) this->status = status; else this->status = 0; if (this->status == 2) this->func(this->funcExtra); return (this->status == 0); } // Draws the button void Button::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)); } void Button::Reset() { if (this->status > 0) this->status = 0; }