/*---------------------------------------------------------------------------* Copyright (C) 2010-2012 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_ASSETS_H_ #define __DEMOWIN_ASSETS_H_ //////////////////////////////////////////////////// // // Assets data, types and interface for demos // //////////////////////////////////////////////////// struct CVec2 { CVec2() {} CVec2(float _x, float _y) : x(_x), y(_y) {} union { struct { float x; float y; }; struct { float u; float v; }; }; }; struct CVec3 { CVec3() {} CVec3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} union { struct { float x; float y; float z; }; struct { float r; float g; float b; }; }; }; struct CVec4 { CVec4() {} CVec4(float _x, float _y, float _z, float _w = 1.0) : x(_x), y(_y), z(_z), w(_w) {} union { struct { float x; float y; float z; float w; }; struct { float r; float g; float b; float a; }; }; }; const float CURSOR_SPEED = 0.02; struct Window; struct TabObject; const int MAX_WINDOWS = 100; const int MAX_NAME_LENGTH = 256; const int MAX_LINE_LENGTH = 80; const int MAX_TEXT_LENGTH = 1000; const float WINDOW_HANDLE_HEIGHT = 0.1; enum CWTextures { CW_TEXTURE_CURSOR = 0, CW_TEXTURE_SLIDERLEFT, CW_TEXTURE_SLIDERRIGHT, CW_TEXTURE_COMBODOWNARROW, CW_NUM_TEXTURES, }; typedef CVec4 (*ColorFunc)(int); typedef void (*VoidFuncP)(void*); /////////////////////////////////////////////////////////////////////////////////////////////////// // Since there is no std::string template struct String { String() {} String(const char* txt) {strcpy_s(text, txt);} String& operator=(const char* txt) {strcpy_s(text, txt); return *this;} operator char*() {return text;} char text[SIZE]; }; #define DEMOWinStringList(...) AutoList(__VA_ARGS__) #define DEMOWinStringListList(...) AutoList >(__VA_ARGS__) #define DEMOWinIntList(...) AutoList(__VA_ARGS__) // Holds any positive number of // Supports any number for POD types, and up to 10 for non-POD types template struct AutoList { AutoList() { count = 0; } AutoList(const T& arg0) {Init(1, &arg0);} AutoList(const T& arg0, const T& arg1) {Init(2, &arg0, &arg1);} AutoList(const T& arg0, const T& arg1, const T& arg2) {Init(3, &arg0, &arg1, &arg2);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3) {Init(4, &arg0, &arg1, &arg2, &arg3);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4) {Init(5, &arg0, &arg1, &arg2, &arg3, &arg4);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5) {Init(6, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5, const T& arg6) {Init(7, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5, const T& arg6, const T& arg7) {Init(8, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5, const T& arg6, const T& arg7, const T& arg8) {Init(9, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8);} AutoList(const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5, const T& arg6, const T& arg7, const T& arg8, const T& arg9) {Init(10, &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9);} AutoList(int _count, const T& arg0, const T& arg1, const T& arg2, const T& arg3, const T& arg4, const T& arg5, const T& arg6, const T& arg7, const T& arg8, const T& arg9, ...) { count = _count; data.resize(count); va_list list; va_start(list, _count); // Figure out where the first element is! for (int i = 0; i < count; ++i) data[i] = va_arg(list, T); va_end(list); } void Init(int _count, ...) { count = _count; data.resize(count); va_list list; va_start(list, _count); // Figure out where the first element is! for (int i = 0; i < count; ++i) data[i] = *va_arg(list, T*); va_end(list); args = &data[0]; } const AutoList& operator=(const AutoList& list) { count = list.count; data.resize(list.data.size()); for (int i = 0; i < list.data.size(); ++i) data = list.data; args = &data[0]; return *this; } T* args; std::vector data; int count; }; /////////////////////////////////////////////////////////////////////////////////////////////////// struct MenuItem; // The structure used for tabbing struct TabObject { TabObject() : active(false), next(this), prev(this) {} TabObject(Window* window) : active(false), next(this), prev(this) {this->window = window;} void Add(Window* window, MenuItem* object, bool active = true); void Remove(); Window* window; MenuItem* object; bool active; TabObject* next; TabObject* prev; }; // The base structure that must be used for the combo box struct SubCombo { virtual const char* GetName() = 0; virtual SubCombo** GetPointers() = 0; virtual int GetCount() = 0; }; // A simple example that has a list of names template struct SubComboBasic : public SubCombo { SubComboBasic(const char* _name) : name(_name) {} SubComboBasic() {} SubComboBasic& operator=(const char* txt) {name = txt; return *this;} virtual const char* GetName() {return name.text;} virtual SubCombo** GetPointers() {return NULL;} virtual int GetCount() {return 0;} String name; }; // A simple example that has a double list of names template struct SubDoubleComboBasic : public SubCombo { SubDoubleComboBasic(const char* _name) : name(_name), count(0) {} SubDoubleComboBasic() {} void SetName(const char* txt) {name = txt;} void AddName(const char* txt) {list[count] = txt; pointers[count] = &list[count]; ++count;} virtual const char* GetName() {return name.text;} virtual SubCombo** GetPointers() {return pointers;} virtual int GetCount() {return count;} String name; SubCombo* pointers[NUM_POINTERS]; SubComboBasic list[NUM_POINTERS]; int count; }; #endif