diff --git a/README.md b/README.md index ef9e08e..049f604 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Universal-Core by Universal-Team This contains the GUI & Core part for our 3DS Applications. +Logo created by: [TotallyNotGuy](https://github.com/TotallyNotGuy). + +![Universal-Core-Logo](https://github.com/Universal-Team/Universal-Core/blob/master/universal-core-logo.png) + Licensing: This software is licensed under the terms of the GPLv3. You can find a copy of the license in the LICENSE file. \ No newline at end of file diff --git a/gui.cpp b/gui.cpp index 8633275..2061fe7 100644 --- a/gui.cpp +++ b/gui.cpp @@ -44,10 +44,16 @@ void Gui::clearTextBufs(void) } // Draw a sprite from the sheet. -void Gui::DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY) +void Gui::DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX, float ScaleY, u32 tintColor) { + // Tint sprite. + C2D_ImageTint tint; + C2D_SetImageTint(&tint, C2D_TopLeft, tintColor, 1); + C2D_SetImageTint(&tint, C2D_TopRight, tintColor, 1); + C2D_SetImageTint(&tint, C2D_BotLeft, tintColor, 1); + C2D_SetImageTint(&tint, C2D_BotRight, tintColor, 1); C2D_Image img = C2D_SpriteSheetGetImage(sheet, imgindex); - C2D_DrawImageAt(img, x, y, 0.5f, NULL, ScaleX, ScaleY); + C2D_DrawImageAt(img, x, y, 0.5f, &tint, ScaleX, ScaleY); } // Initialize GUI. diff --git a/gui.hpp b/gui.hpp index 866b381..69035b9 100644 --- a/gui.hpp +++ b/gui.hpp @@ -40,7 +40,7 @@ namespace Gui void clearTextBufs(void); // Draw a sprite from a sheet. - void DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX = 1, float ScaleY = 1); + void DrawSprite(C2D_SpriteSheet sheet, size_t imgindex, int x, int y, float ScaleX = 1, float ScaleY = 1, u32 tintColor = C2D_Color32(0, 0, 0, 0)); // Initialize the GUI with Citro2D & Citro3D and initialize the Textbuffer. Result init(void); diff --git a/hid.cpp b/hid.cpp new file mode 100644 index 0000000..f29df70 --- /dev/null +++ b/hid.cpp @@ -0,0 +1,75 @@ +/* +* This file is part of Universal-Core +* Copyright (C) 2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#include "hid.hpp" + +HID::HID(size_t EntryPerPage, size_t EntryAmount) { + maxEntries = EntryAmount; + pageEntry = EntryPerPage; +} + +size_t HID::getIndex() { + return currentEntry; +} + +size_t HID::getMaxEntries() { + return maxEntries; +} + +void HID::nextEntry() { + if (currentEntry < maxEntries-1) { + currentEntry++; + } +} + +void HID::lastEntry() { + if (currentEntry > 0) { + currentEntry--; + } +} + +void HID::nextPage() { + // Only go to the next page, if the next Page doesn't reach the maxEntries. + if (currentEntry + pageEntry < maxEntries - 1) { + currentPage++; + currentEntry += pageEntry; + // If the first index of the page is smaller than maxEntries -> Go to the next page. + } else if (currentPage * pageEntry < maxEntries - 1) { + currentPage++; + currentEntry = currentPage * pageEntry; + } +} + +size_t HID::getPage() { + return currentPage; +} + +void HID::prevPage() { + if (currentPage > 0) { + currentPage--; + currentEntry -= pageEntry; + } +} \ No newline at end of file diff --git a/hid.hpp b/hid.hpp new file mode 100644 index 0000000..51c1c3e --- /dev/null +++ b/hid.hpp @@ -0,0 +1,59 @@ +/* +* This file is part of Universal-Core +* Copyright (C) 2020 DeadPhoenix8091, Epicpkmn11, Flame, RocketRobz, StackZ, TotallyNotGuy +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Additional Terms 7.b and 7.c of GPLv3 apply to this file: +* * Requiring preservation of specified reasonable legal notices or +* author attributions in that material or in the Appropriate Legal +* Notices displayed by works containing it. +* * Prohibiting misrepresentation of the origin of that material, +* or requiring that modified versions of such material be marked in +* reasonable ways as different from the original version. +*/ + +#ifndef HID_HPP +#define HID_HPP + +#include + +class HID +{ +public: + // The parameters to initialize this class. + HID(size_t EntryPerPage, size_t EntryAmount); + // get the current index. + size_t getIndex(); + // get the max amount of the index. + size_t getMaxEntries(); + // Go to the next Entry, if maxEntries is not reached. + void nextEntry(); + // Go to the last Entry, if 0 is not reached. + void lastEntry(); + // Go to the next Page. + void nextPage(); + // Go to the previous Page. + void prevPage(); + // Get the current page. + size_t getPage(); + +private: + size_t maxEntries; + size_t currentEntry = 0; + size_t pageEntry; + size_t currentPage = 0; +}; + +#endif \ No newline at end of file diff --git a/universal-core-logo.png b/universal-core-logo.png new file mode 100644 index 0000000..5e8bf1d Binary files /dev/null and b/universal-core-logo.png differ