/*---------------------------------------------------------------------------* 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. *---------------------------------------------------------------------------*/ #ifndef __DEMOWIN_H_ #define __DEMOWIN_H_ #include #include #include #include #include #include #include #include #include namespace DEMOWin { #include "demowin/demowin_assets.h" #include "demowin/demowin_helpers.h" /////////////////////////////////////////////////////////////////////////////////////////////////// struct WindowManager; struct ScrollBar; // This window is more generic, and can scroll vertically struct Window { Window(WindowManager* manager, const char* _name, CVec2 _position, CVec2 _size, CVec2 _maxSize = CVec2(0, 0), bool _canKill = true); ~Window(); void Delete() {this->deleteFlag = true; this->visible = false;} bool Deleted() {return this->deleteFlag;} const char* GetName() {return name.text;} void SetName(const char* name) {this->name = name;} float GetX() {return this->x;} float GetY() {return this->y + this->offY;} float& GetOffY(); float GetWidth(); float GetHeight(); float GetMaxHeight(); float GetLeft() {return this->x - GetWidth() / 2;} float GetRight() {return this->x + GetWidth() / 2;} float GetTop(); float GetBottom(){return this->GetTop() - GetHeight();} Window* GetMaster(); virtual void GetData(void*& data, int& size) {data = NULL; size = 0;} virtual bool CursorOver(); virtual bool Update(bool canUpdate) {return canUpdate;} virtual void Draw() {} virtual void Reset(); virtual bool PreUpdate(bool canUpdate); virtual void PreDraw(); virtual void Hide(); virtual void Show(); bool Visible(); bool Enabled(); void Enable() {this->enabled = true;} void Disable() {this->enabled = false;} bool Active() {return this->Visible() && this->Enabled();} bool InFront(); void BringToFront(); virtual void ClearItems(); MenuItem* Menu() {return menu;} void AddTabbing(MenuItem* item); TabObject* DummyTab() {return &dummyTab;} void AttachWindow(Window* window); void DetachWindow(); String name; int number; CVec2 position; CVec2 size; CVec2 maxSize; float& x; float& y; float offY; float& width; float& height; float& maxWidth; float& maxHeight; bool canKill; int closeStatus; std::list menuItems; WindowManager* manager; Window* master; Window* child; protected: bool deleteFlag; ScrollBar* scrollBar; TabObject dummyTab; MenuItem* menu; bool visible; bool enabled; std::list sortedItems; std::list sortedDrawItems; std::list tabItems; friend TabObject; friend WindowManager; }; // Has a single combo box, no core (max 10 options) struct ComboCustom : public Window { ComboCustom(WindowManager* manager, const char* name, const AutoList& start, const AutoList& names, const AutoList >& option); ComboCustom(WindowManager* manager, const char* name, const AutoList& start, const AutoList& names, const AutoList >& option); ComboCustom(WindowManager* manager, const char* name, const std::vector& start, const std::vector& names, const std::vector >& option); void Init(int num, const int* counts, const int* start, const char* const* names, const char* const* const* option); std::vector > options[10]; std::vector optionsList[10]; int choice[10]; }; #include "demowin/demowin_manager.h" struct MenuItem { MenuItem(Window* _window, const CVec3& _position = CVec3(0, 0, 0), const CVec2& _size = CVec2(0, 0)) : window(_window), visible(true), position(_position), size(_size), x(position.x), y(position.y), z(position.z), width(size.x), height(size.y), status(0) {} MenuItem(const MenuItem& copy) : window(copy.window), visible(copy.visible), position(copy.position), size(copy.size), x(position.x), y(position.y), z(position.z), width(size.x), height(size.y), status(copy.status) {} virtual bool CursorOver() {return false;} virtual bool Update() {return true;} virtual void Draw() {} virtual void Reset() {} virtual bool Active() {return this->visible && this->status >= 0;} // Draw calls void DrawText(const char* text, CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawText(text, CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawTextCenter(const char* text, CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawTextCenter(text, CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawTextRight(const char* text, CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawTextRight(text, CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawMultiLineText(const char* text, CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawMultiLineText(text, CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawBox(CVec3 position, CVec2 size, CVec4 color, CVec4 color1 = CVec4(0, 0, 0, 1.0)) {window->manager->peripheral->DrawBox(CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color, color1);} void DrawLine(CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawLine(CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawFastLine(CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawFastLine(CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawQuad(CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawQuad(CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawTexQuad(GX2Texture* tex, CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawTexQuad(tex, CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} void DrawBoxQuad(CVec3 position, CVec2 size, CVec4 color) {window->manager->peripheral->DrawBoxQuad(CVec3(window->GetX() + position.x, window->GetY() + position.y, position.z), size, color);} GX2Texture** GetTexture(CWTextures num) {return window->manager->GetTexture(num);} // Input checks bool AnyPressed() {return window->manager->peripheral->AnyPressed();} bool LeftPressed() {return window->manager->peripheral->LeftPressed();} bool RightPressed() {return window->manager->peripheral->RightPressed();} bool UpPressed() {return window->manager->peripheral->UpPressed();} bool DownPressed() {return window->manager->peripheral->DownPressed();} bool PositivePressed() {return window->manager->peripheral->PositivePressed();} bool NegativePressed() {return window->manager->peripheral->NegativePressed();} bool LeftTriggered() {return window->manager->peripheral->LeftTriggered();} bool RightTriggered() {return window->manager->peripheral->RightTriggered();} bool UpTriggered() {return window->manager->peripheral->UpTriggered();} bool DownTriggered() {return window->manager->peripheral->DownTriggered();} bool PositiveTriggered() {return window->manager->peripheral->PositiveTriggered();} bool NegativeTriggered() {return window->manager->peripheral->NegativeTriggered();} bool TabLeftTriggered() {return window->manager->peripheral->TabLeftTriggered();} bool TabRightTriggered() {return window->manager->peripheral->TabRightTriggered();} bool PauseTriggered() {return window->manager->peripheral->PauseTriggered();} bool HomeTriggered() {return window->manager->peripheral->HomeTriggered();} bool CursorColliding(float x, float y, float width, float height, bool ignoreBounds = false) {return window->manager->peripheral->CursorColliding(window, x, y, width, height, ignoreBounds);} bool UsingPad() {return window->manager->peripheral->UsingPad();} bool UsingWiimote() {return window->manager->peripheral->UsingWiimote();} float& CursorX() {return window->manager->peripheral->CursorX();} float& CursorY() {return window->manager->peripheral->CursorY();} TabObject*& TabIndex() {return (window->manager->tabIndex);} int& TabSubIndex() {return (window->manager->tabSubIndex);} int& CursorTime() {return (window->manager->cursorTime);} Window* window; CVec3 position; CVec2 size; float& x; float& y; float& z; float& width; float& height; bool visible; int status; }; #include "demowin/demowin_object_list.h" #include "demowin/demowin_tab_window.h" } #endif